Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 KB | None | 0 0
  1. !/usr/bin/python -W ignore::DeprecationWarning
  2.  
  3. import socket
  4. import re
  5. import sys
  6. import base64
  7. import hashlib
  8.  
  9. def main():
  10.     password = "unix"
  11.     HOST = 'wargame.securitybydefault.com'
  12.     PORT = 8008
  13.     try:
  14.       s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  15.       s.connect((HOST, PORT))
  16.       data1 = s.recv(1024)
  17.       data2 = s.recv(1024)
  18.       nonce1 = base64.decodestring(data2)
  19.       print nonce1
  20.       nonce1 = base64.decodestring(data2[186:-12].replace('\n',''))
  21.       print nonce1
  22.       nonce = nonce1[7:-45]
  23.       print nonce
  24.       username = "zero_cool"
  25.       realm = "war.game.sbd"
  26.       nc = "00000001"
  27.       qop = "auth"
  28.       digest_uri = "xmpp/war.game.sbd"
  29.       charset = "utf-8"
  30.       cnonce = '1238741923'
  31.       hash = hashlib.md5()
  32.       hash.update(username + ":" + realm + ":" + password)
  33.       hA1data = hash.digest()
  34.       hA1data = hA1data + ":" + nonce + ":" + cnonce
  35.       hash = hashlib.md5()
  36.       hash.update(hA1data)
  37.       hA1 = hash.hexdigest()
  38.       hash = hashlib.md5()
  39.       hash.update("AUTHENTICATE:"+digest_uri)
  40. hA2 = hash.hexdigest()
  41.       hash = hashlib.md5()
  42.       hash.update(hA1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + hA2)
  43.       hashfinal = hash.hexdigest()
  44.       RESPONSE = 'username="zero_cool",nc=00000001,realm="war.game.sbd",digest-uri="xmpp/war.game.sbd",nonce="' + nonce + '",cnonce="1310590878",qop="auth",charset=utf-8,response=' + hashfinal+ ''
  45.       print 'HASH: ' + hashfinal + ' - ',
  46.       RESPONSEB64 = base64.encodestring(RESPONSE)
  47.       print 'ENCODED_DATA: ' + RESPONSEB64 + '-',
  48.       s.send('<response>' + RESPONSEB64 + '</response>\n')
  49.       data3 = s.recv(1024)
  50.       print 'ANSWER: ' + data3
  51.       #o.write('PASSWORD: ' + password + ' - ANSWER: ' + data3 + '\n')
  52.       print 'PASSWORD: ' + password + ' - ANSWER: ' + data3 + '\n'
  53.       #count = count + 1
  54.       #s.close()
  55.     except socket.gaierror:
  56.       print 'The server ' + HOST + ' does not exist'
  57.     except socket.error:
  58.       print 'Port ' + str(PORT) + ' is NOT open on ' + HOST
  59.  
  60. # This is the standard boilerplate that calls the main() function.
  61. if __name__ == '__main__':
  62.   main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement