Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !/usr/bin/python -W ignore::DeprecationWarning
- import socket
- import re
- import sys
- import base64
- import hashlib
- def main():
- password = "unix"
- HOST = 'wargame.securitybydefault.com'
- PORT = 8008
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((HOST, PORT))
- data1 = s.recv(1024)
- data2 = s.recv(1024)
- nonce1 = base64.decodestring(data2)
- print nonce1
- nonce1 = base64.decodestring(data2[186:-12].replace('\n',''))
- print nonce1
- nonce = nonce1[7:-45]
- print nonce
- username = "zero_cool"
- realm = "war.game.sbd"
- nc = "00000001"
- qop = "auth"
- digest_uri = "xmpp/war.game.sbd"
- charset = "utf-8"
- cnonce = '1238741923'
- hash = hashlib.md5()
- hash.update(username + ":" + realm + ":" + password)
- hA1data = hash.digest()
- hA1data = hA1data + ":" + nonce + ":" + cnonce
- hash = hashlib.md5()
- hash.update(hA1data)
- hA1 = hash.hexdigest()
- hash = hashlib.md5()
- hash.update("AUTHENTICATE:"+digest_uri)
- hA2 = hash.hexdigest()
- hash = hashlib.md5()
- hash.update(hA1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + hA2)
- hashfinal = hash.hexdigest()
- 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+ ''
- print 'HASH: ' + hashfinal + ' - ',
- RESPONSEB64 = base64.encodestring(RESPONSE)
- print 'ENCODED_DATA: ' + RESPONSEB64 + '-',
- s.send('<response>' + RESPONSEB64 + '</response>\n')
- data3 = s.recv(1024)
- print 'ANSWER: ' + data3
- #o.write('PASSWORD: ' + password + ' - ANSWER: ' + data3 + '\n')
- print 'PASSWORD: ' + password + ' - ANSWER: ' + data3 + '\n'
- #count = count + 1
- #s.close()
- except socket.gaierror:
- print 'The server ' + HOST + ' does not exist'
- except socket.error:
- print 'Port ' + str(PORT) + ' is NOT open on ' + HOST
- # This is the standard boilerplate that calls the main() function.
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement