Skip to content

Commit

Permalink
Merge pull request SECFORCE#12 from jayslovak/master
Browse files Browse the repository at this point in the history
Basic HTTP authentication improvement
  • Loading branch information
nvssks authored Aug 5, 2017
2 parents d37ee60 + d5695b6 commit 7074493
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def main():
advancedGroup.add_option('-s','--start-ping', help='Start the pinging thread first - some services send data first (eg. SSH)', dest='start_p_thread', action='store_true', default=Defaults['start_p_thread'])
advancedGroup.add_option('-c','--verify-server-cert', help='Verify Server Certificate', dest='start_p_thread', action='store_false', default=Defaults['ignoreServerCert'])
advancedGroup.add_option('-C','--cookie', help='Request cookies', dest='cookie', action='store')
advancedGroup.add_option('-t','--authentication', help='Basic authentication', dest='bauth', action='store_true')
advancedGroup.add_option('-t','--authentication', help='Basic authentication (username:password or \'-\' for stdin input', dest='bauth', action='store', default='no')

parser.add_option_group(advancedGroup)

Expand Down Expand Up @@ -100,10 +100,13 @@ def main():
proxy_digest_handler = urllib2.ProxyDigestAuthHandler(password_mgr)

options['upProxyAuth']=[proxy_handler,proxy_basic_handler,proxy_digest_handler]
if options['bauth']: # Basic authentication
username=raw_input("Basic Authentication\nUsername:")
from getpass import getpass
passwd=getpass("Password:")
if not options['bauth'] == 'no': # Basic authentication
if options['bauth'] == '-':
username=raw_input("Basic Authentication\nUsername:")
from getpass import getpass
passwd=getpass("Password:")
else:
username, passwd = options['bauth'].split(':')

options['bauth'] = b64encode('%s:%s' % (username, passwd))

Expand Down

0 comments on commit 7074493

Please sign in to comment.