Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! / Usr / bin / python
- # Drupal modules scanner
- import os, sys, socket, Subprocess
- __Cmd__ = {
- # WGET
- "Wget" : "wget-q-O -" ,
- "Grep" : "| grep modules" ,
- "Output_File" : "cat" ,
- "Help" : "Drupal Modules Enumerator V0.1Beta-- written by Ali Elouafiq 2012"
- "\ N <ScriptName> [filename.txt]"
- "\ N <ScriptName> [URL]"
- "\ N <ScriptName> [URL] user password / / FOR HTTP AUTHORIZATION"
- }
- __Debug_Mode__ = "off"
- def call (command):
- p = Subprocess.popen ([command], shell = True , stdin = Subprocess.pipe, stdout = Subprocess.pipe, stderr = Subprocess.pipe)
- if ( len (P.stdout.readlines ()) + len (P.stderr.readlines ()))> the 0th :
- raise Commandfailure (command)
- def main ():
- # Check options
- Modules_List = []
- command = ""
- if len (Sys.argv) = = an :
- print __Cmd__ [ "help" ]
- else :
- if len (Sys.argv) = = the second :
- url = Sys.argv [ 1 ]
- if len (Url.split ( ". txt" ))> the first :
- command = " "+ __Cmd__ [" Output_File "] + url
- else : command = " "+ __Cmd__ [" wget "] + url
- if len (Sys.argv) = = the 4th :
- url = Sys.argv [ 1 ]
- user = Sys.argv [ 2nd ]
- password = Sys.argv [ third ]
- command = " "+ __Cmd__ [" wget "] + url +" - - http - user "+ user +" - - http - password " + password
- # Retrieves the Page
- command = command + __Cmd__ [ "grep" ]
- # --- Command:
- p = Subprocess.popen ([command], shell = True , stdin = Subprocess.pipe, stdout = Subprocess.pipe, stderr = Subprocess.pipe)
- if __Debug_Mode__ = = "wget" : print P.stdout
- # SCAN the page
- for line in P.stdout:
- line = Line.split ( "modules" )
- if len (line)> 1 :
- Modules_List.append (line [ the first ]. split ( "/" ) [ the first ])
- # Retrieve Results
- Modules_List = list ( set (Modules_List))
- for module in Modules_List:
- print module
- if __Name__ = = "__Main__" :
- main ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement