#!/usr/local/bin/python2.5 ''' urlencode.py Copyright 2006 Andres Riancho This file is part of w3af, w3af.sourceforge.net . w3af is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License. w3af is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with w3af; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ''' import urllib import sys import getopt try: import core.controllers.outputManager as om except: class om: class out: def information( str ): print '\r' + str information = staticmethod(information) def usage(): om.out.information('w3af - urlencoder') om.out.information('') om.out.information('Options:') om.out.information(' -h Print this help message.') om.out.information(' -s Characters that should not be encoded, default is / .') om.out.information(' -e String to be encoded.') om.out.information('') om.out.information('Example: urlencode -s &% -e encodeMeNow') def main(): try: opts, args = getopt.getopt(sys.argv[1:], "hs:e:", ["help", "safe","encode"]) except getopt.GetoptError: # print help information and exit: usage() sys.exit(2) safe = '' encode = None for o, a in opts: if o in ("-s", "--safe"): safe = a if o in ("-e", "--encode"): encode = a if o in ("-h", "--help"): usage() sys.exit() if encode == None: usage() sys.exit() else: om.out.information( urllib.quote_plus( encode, safe ) ) if __name__ == "__main__": main()