1+ import base64
2+ from lib .common import helpers
3+
4+ class Module :
5+
6+ def __init__ (self , mainMenu , params = []):
7+
8+ self .info = {
9+ 'Name' : 'Find-Fruit' ,
10+
11+ 'Author' : ['@424f424f' ],
12+
13+ 'Description' : ("Searches a network range for potentially vulnerable web services." ),
14+
15+ 'Background' : True ,
16+
17+ 'OutputExtension' : None ,
18+
19+ 'NeedsAdmin' : False ,
20+
21+ 'OpsecSafe' : True ,
22+
23+ 'MinPSVersion' : '2' ,
24+
25+ 'Comments' : [
26+ 'Inspired by mattifestation Get-HttpStatus in PowerSploit'
27+ ]
28+ }
29+
30+ # any options needed by the module, settable during runtime
31+ self .options = {
32+ # format:
33+ # value_name : {description, required, default_value}
34+ 'Agent' : {
35+ 'Description' : 'Agent to run module on.' ,
36+ 'Required' : True ,
37+ 'Value' : ''
38+ },
39+ 'Rhosts' : {
40+ 'Description' : 'Specify the CIDR range or host to scan.' ,
41+ 'Required' : True ,
42+ 'Value' : ''
43+ },
44+ 'Port' : {
45+ 'Description' : 'Specify the port to scan.' ,
46+ 'Required' : False ,
47+ 'Value' : ''
48+ },
49+ 'Path' : {
50+ 'Description' : 'Specify the path to a dictionary file.' ,
51+ 'Required' : False ,
52+ 'Value' : ''
53+ },
54+ 'Timeout' : {
55+ 'Description' : 'Set timeout for each connection in milliseconds' ,
56+ 'Required' : False ,
57+ 'Value' : '50'
58+ },
59+ 'UseSSL' : {
60+ 'Description' : 'Force SSL useage.' ,
61+ 'Required' : False ,
62+ 'Value' : ''
63+ },
64+ 'ShowAll' : {
65+ 'Description' : 'Switch. Show all results (default is to only show 200s).' ,
66+ 'Required' : False ,
67+ 'Value' : ''
68+ }
69+ }
70+
71+ # save off a copy of the mainMenu object to access external functionality
72+ # like listeners/agent handlers/etc.
73+ self .mainMenu = mainMenu
74+
75+ for param in params :
76+ # parameter format is [Name, Value]
77+ option , value = param
78+ if option in self .options :
79+ self .options [option ]['Value' ] = value
80+
81+
82+ def generate (self ):
83+
84+ # read in the common module source code
85+ moduleSource = self .mainMenu .installPath + "/data/module_source/recon/Find-Fruit.ps1"
86+
87+ try :
88+ f = open (moduleSource , 'r' )
89+ except :
90+ print helpers .color ("[!] Could not read module source path at: " + str (moduleSource ))
91+ return ""
92+
93+ moduleCode = f .read ()
94+ f .close ()
95+
96+ script = moduleCode
97+
98+ script += "\n Find-Fruit"
99+
100+ showAll = self .options ['ShowAll' ]['Value' ].lower ()
101+
102+ for option ,values in self .options .iteritems ():
103+ if option .lower () != "agent" and option .lower () != "showall" :
104+ if values ['Value' ] and values ['Value' ] != '' :
105+ if values ['Value' ].lower () == "true" :
106+ # if we're just adding a switch
107+ script += " -" + str (option )
108+ else :
109+ script += " -" + str (option ) + " " + str (values ['Value' ])
110+
111+ if showAll != "true" :
112+ script += " | ?{$_.Status -eq 'OK'}"
113+
114+ script += " | Format-Table -AutoSize | Out-String"
115+
116+ return script
0 commit comments