Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Anonymous
Friday, August 3rd, 2012 at 11:30:39am UTC 

  1. #!/usr/bin/env python
  2.  
  3. import getopt, sys, os
  4. import gettext
  5.  
  6. # First of all, we need to change the working directory to the directory of w3af.
  7. currentDir = os.getcwd()
  8. scriptDir = os.path.dirname(sys.argv[0]) or '.'
  9. os.chdir( scriptDir )
  10.  
  11. def backToCurrentDir():
  12.     os.chdir( currentDir )
  13.  
  14. # Translation stuff
  15. gettext.install('w3af', 'locales/')
  16.  
  17. # Now we can load all modules and stuff...
  18. from core.controllers.w3afException import w3afException
  19. import core.controllers.outputManager as om
  20.  
  21. try:
  22.     om.out.setOutputPlugins( ['console'] )
  23. except w3afException, w3:
  24.     print 'Something went wrong, w3af failed to init the output manager. Exception: ', str(w3)
  25.     sys.exit(-9)
  26.    
  27.  
  28. def usage():
  29.     om.out.information('w3af - Web Application Attack and Audit Framework')
  30.     om.out.information('')
  31.     om.out.information('Options:')
  32.     om.out.information('    -h              Print this help message.')
  33.     om.out.information('    -s <file>       Execute a script file.')
  34.     om.out.information('    -i <dir>        Directory where MSF is installed (only used to install the virtual daemon).')
  35.     om.out.information('    -p <profile>    Run with the selected profile')
  36.     om.out.information('')
  37.     om.out.information('http://w3af.sourceforge.net/')
  38.  
  39. def main():
  40.     try:
  41.         opts, args = getopt.getopt(sys.argv[1:], "p:i:hs:get", [] )
  42.     except getopt.GetoptError:
  43.         # print help information and exit:
  44.         usage()
  45.         return -3
  46.     scriptFile = None
  47.     profile = None
  48.     for o, a in opts:
  49.         if o in ( "-e"  ):
  50.             # easter egg
  51.             import base64
  52.             om.out.information( base64.b64decode( 'R3JhY2lhcyBFdWdlIHBvciBiYW5jYXJtZSB0YW50YXMgaG9yYXMgZGUgZGVzYXJyb2xsbywgdGUgYW1vIGdvcmRhIQ==' ) )
  53.         if o in ( "-t"  ):
  54.             # Test all scripts that have an assert call
  55.             from core.controllers.misc.w3afTest import w3afTest
  56.             w3afTest()
  57.             return 0
  58.         if o == "-s":
  59.             scriptFile = a
  60.         if o == "-i":
  61.             # Install the virtual daemon module in the MSF directory
  62.             from core.controllers.vdaemon.install import installVdaemon
  63.             installVdaemon( a )
  64.         if o in ('-p', '--profile'):
  65.             # selected profile
  66.             profile = a
  67.         if o == "-h":
  68.             usage()
  69.             return 0
  70.    
  71.     # console
  72.     from core.ui.consoleUi.consoleUi import consoleUi
  73.    
  74.     commandsToRun = []
  75.     if scriptFile != None:
  76.         try:
  77.             fd = open( scriptFile )
  78.         except:
  79.             om.out.error('Failed to open file : ' + scriptFile )
  80.             sys.exit(2)
  81.         else:
  82.             commandsToRun = []
  83.             for line in fd:   
  84.                 line = line.strip()
  85.                 if line != '' and line[0] != '#':   # if not a comment..
  86.                     commandsToRun.append( line )
  87.             fd.close()
  88.     elif profile is not None:
  89.         commandsToRun = ["profiles use %s" % profile]
  90.  
  91.     console = consoleUi(commands=commandsToRun)
  92.     console.sh()
  93.  
  94.  
  95. if __name__ == "__main__":
  96.     errCode = main()
  97.     backToCurrentDir()
  98.     sys.exit(errCode)

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right