Jump to content
Gonzalez

[Python] Encode Bot

Recommended Posts

Posted

faza posted this, its basic but can come in handy if you need a quick hash or string encoding/decoding performed on irc.

(hex/base64/md5/sha/sha224/sha512/sha256/sha384/url) !comm for commands.

#!/usr/bin/python
#Hash Irc Bot
import socket, md5, base64, urllib, hashlib, sha

#Config################
ircserv = raw_input(u'server: ')
port = 6667
chan = raw_input(u'channel: ')
nick = raw_input(u'bot nick: ')
readbuffer = ""
#####################

irc = socket.socket (socket.AF_INET, socket.SOCK_STREAM )
try:
irc.connect((ircserv, port))
except: print 'error!'
print irc.recv(4096)
irc.send('NICK '+nick+'\r\n')
irc.send('USER ' +(nick+' ')*3+' :Python IRC\r\n')
req=irc.recv(768)
#irc.send ('PONG :'+req.replace('PING :',''))
print 'PING? PONG!'
irc.send ('JOIN '+chan+'\r\n')

while 1:
readbuffer=readbuffer+irc.recv(10240)
temp=str.split(readbuffer, "\n")
readbuffer=temp.pop( )

for line1 in temp:
line1=str.rstrip(line1)
if line1.find("!quit ")>0:
irc.send ('QUIT '+ line1.split('!quit ')[1]+'\r\n')
print 'bot quit'
if line1.find("!comm")>0:
irc.send ('PRIVMSG '+ chan + ' :!hex, !unhex, !b64, !unb64, !md5, !sha, !sha224, !sha512, !sha256, !sha384, !url, !unurl, !hash\r\n')
print 'function !comm'
if line1.find("!md5 ")>0:
irc.send ('PRIVMSG ' + chan + ' :md5: '+ md5.new(line1.split('!md5 ')[1]).hexdigest()+'\r\n')
print 'function !md5'
if line1.find("!hex ")>0:
irc.send ('PRIVMSG ' + chan + ' :hex: 0x'+ base64.binascii.hexlify(line1.split('!hex ')[1]) + '\r\n')
print 'function !hex'
if line1.find("!b64 ")>0:
irc.send ('PRIVMSG ' + chan + ' :base64: '+ base64.binascii.b2a_base64(line1.split('!b64 ')[1]) + '\r\n')
print 'function !b64'
if line1.find("!url ")>0:
irc.send ('PRIVMSG ' + chan + ' :url: '+ urllib.quote(line1.split('!url ')[1]) + '\r\n')
print 'function !url'
if line1.find("!unurl ")>0:
irc.send ('PRIVMSG ' + chan + ' :unurl: '+ urllib.unquote(line1.split('!unurl ')[1]) + '\r\n')
print 'function !unurl'
if line1.find("!unb64 ")>0:
irc.send ('PRIVMSG ' + chan + ' :unbase64: '+ base64.binascii.a2b_base64(line1.split('!unb64 ')[1]) + '\r\n')
print 'function !unb64'
if line1.find("!unhex ")>0:
irc.send ('PRIVMSG ' + chan + ' :unhex: '+ base64.binascii.unhexlify(line1.split('!unhex 0x')[1]) + '\r\n')
print 'function !unhex'
if line1.find("!sha ")>0:
irc.send ('PRIVMSG ' + chan + ' :sha-1: '+ sha.new(line1.split('!sha ')[1]).hexdigest() + '\r\n')
print 'function !sha'
if line1.find("!sha224 ")>0:
irc.send ('PRIVMSG ' + chan + ' :sha-224: '+ hashlib.sha224(line1.split('!sha224 ')[1]).hexdigest() + '\r\n')
print 'function !sha224'
if line1.find("!sha256 ")>0:
irc.send ('PRIVMSG ' + chan + ' :sha-256: '+ hashlib.sha256(line1.split('!sha256 ')[1]).hexdigest() + '\r\n')
print 'function !sha256'
if line1.find("!sha384 ")>0:
irc.send ('PRIVMSG ' + chan + ' :sha-384: '+ hashlib.sha384(line1.split('!sha384 ')[1]).hexdigest() + '\r\n')
print 'function !sha384'
if line1.find("!sha512 ")>0:
irc.send ('PRIVMSG ' + chan + ' :sha-512: '+ hashlib.sha512(line1.split('!sha512 ')[1]).hexdigest() + '\r\n')
print 'function !sha512'
if line1.find("!hash ")>0:
print 'function !hash'
go=line1.split('!hash ')[1]
if len(go)==32:
irc.send ('PRIVMSG ' + chan + ' :hash type: MD5/MSCash/MD2/MD4/Haval128/NTLM/RipeMD128\r\n')
if go.find('==') != -1:
irc.send ('PRIVMSG ' + chan + ' :hash type: MD5(Base64)\r\n')
if go.find('$1$$') != -1:
irc.send ('PRIVMSG ' + chan + ' :hash type: MD5(Unix)\r\n')
if go.find('$apr1$$') != -1:
irc.send ('PRIVMSG ' + chan + ' :hash type: MD5(APR)\r\n')
if len(go)==16:
irc.send ('PRIVMSG ' + chan + ' :hash type: MySQL\r\n')
if len(go)==40:
irc.send ('PRIVMSG ' + chan + ' :hash type: MySQL5/SHA-1\r\n')
if len(go)==13:
irc.send ('PRIVMSG ' + chan + ' :hash type: DES(Unix)\r\n')
if len(go)==28:
irc.send ('PRIVMSG ' + chan + ' :hash type: SHA-1(Base64)\r\n')
if len(go)==8:
irc.send ('PRIVMSG ' + chan + ' :hash type: ADLER32/CRC-32\r\n')
if len(go)<=5:
irc.send ('PRIVMSG ' + chan + ' :error!\r\n')

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...