torIRC mini ver.

[chan] 1st amendment
Dec 12 03:21

#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- __author__="version 2 of torifier from " # minified version easy to audit # release home site: https://gist.github.com/torifier/f1a7c1ac7b6b003cd9e1c187df2c5347 __date__="$ Dec 11, 2017 $" import curses from threading import Thread from optparse import OptionParser import time,os,subprocess import socket,select,random,sys import tempfile minimum_message_len = 256 tor_server= '127.0.0.1' # i.e. localhost tor_server_control_port = 9051 # 9051 tor_server_socks_port = 9050 # TBB offers 9150 instead of 9050 hidden_service_interface= '127.0.0.1' hidden_service_port = 11009 # inform your clients if changed away from :11009 standard port clientRandomWait = 2 clientRandomNoise = 5 serverRandomWait = 2 buddywidth = 20 chantext =[] roster =[] class torStem(): def connect(self,addr='127.0.0.1',cport=9051): print("[I] Connecting to TOR via Stem library") try: from stem.control import Controller except: print "[E] Cannot load stem module." print "[E] Try installing python-stem with the package manager of your distro ( apt, 'pacman' or whatever)" exit(0) self.controller=Controller.from_port(address=addr,port=cport) self.controller.authenticate() bytes_read=self.controller.get_info("traffic/read") bytes_written=self.controller.get_info("traffic/written") print "[I] Tor relay is alive. %s bytes read, %s bytes written."%(bytes_read,bytes_written) print "[C] Tor Version: %s"%str(self.controller.get_version()) try: self.SocksPort=self.controller.get_conf("SocksPort") if self.SocksPort==None: self.SocksPort=9050 else: self.SocksPort=int(self.SocksPort) print "[C] Socks port is: %d"%self.SocksPort except: print "[E] Failed to get Socks port, trying 127.0.0.1:9050..." self.SocksPort=9050 pass print "[I] Adding hidden service. Hit CTRL-C to stop server afterwards. Please wait ca. one minute until hidden service is ready." self.hostname=self.controller.create_ephemeral_hidden_service({hidden_service_port:'%s:%d'%(hidden_service_interface,hidden_service_port)},await_publication=True).service_id+'.onion' print "[C] Hostname is %s"%self.hostname def disconnect(self): print "Removing hidden service and shutting down torIRC." self.controller.remove_ephemeral_hidden_service(self.hostname.replace('.onion','')) STDoutLog=False def addpadding(message): if len(message)<minimum_message_len: message+=chr(0) for i in range(minimum_message_len-len(message)): message+=chr(random.randint(ord('a'),ord('z'))) return message def sanitize(string): out="" for c in string: if(ord(c)==0):break if(ord(c)>=0x20)and(ord(c)<0x80): out+=c return out def log(text): if(STDOutLog): print text else: maxlen=width-buddywidth-1 while(True): if(len(text[:maxlen])>0): chantext.append(text[:maxlen]) text=text[maxlen:] if text=='': break redraw(stdscr) stdscr.refresh() class Server(): serverRoster={} servermsgs=[] channelname="" def serverRosterCleanThread(self): while True: time.sleep(10) current=time.time() waittime=random.randint(01*60*01,01*60*02) for b in self.serverRoster: if current-self.serverRoster[b]>waittime: self.serverRoster.pop(b) waittime=random.randint(01*60*10,01*60*15) def serverThread(self,conn,addr,msg,nick): log("(ServerThread): Received connection - a buddy connected !") conn.setblocking(0) randomwait=random.randint(1,serverRandomWait) while(True): try: time.sleep(1) ready=select.select([conn],[],[],1.0) if ready[0]: data=sanitize(conn.recv(minimum_message_len)) if len(data)==0:continue message="%s: %s"%(nick,data) if data.startswith("/PING"): message="" msg.append(data) continue if data.startswith("/nick "): newnick=data[6:].strip() if newnick.startswith("--"):continue log("Nick change: %s->%s"%(nick,newnick)) nick=newnick self.serverRoster[newnick]=time.time() message="Nick changed to %s"%newnick msg.append(message) continue if data.startswith("/roster"): message="--roster" message+=" %s"%self.channelname totalbuddies=len(self.servermsgs) for r in self.serverRoster: message+=" %s"%r totalbuddies-=1 message+=" --anonymous:%d"%totalbuddies msg.append(message) continue if data.startswith("/serverhelp"): msg.append("These are the commands which are supported:") msg.append(" /serverhelp : Send this help text") msg.append(" /roster : Send the list of connected buddies") msg.append(" /nick <my-new-name> : Changes your nickname") continue self.serverRoster[nick]=time.time() for m in self.servermsgs: m.append(message) if len(msg)>0: randomwait-=1 if randomwait==0: m=addpadding(msg.pop(0)) conn.sendall(m) randomwait=random.randint(1,serverRandomWait) if random.randint(0,clientRandomNoise)==0: ping="/PING " for i in range(120): ping+="%02X"%random.randint(ord('a'),ord('z')) msg.append(ping) except: self.servermsgs.remove(msg) conn.close() print "exiting: msgs %d"%len(self.servermsgs) raise def serverMain(self,channel_name): global STDOutLog STDOutLog=True self.channelname=channel_name self.ts=torStem() try: self.ts.connect(tor_server,tor_server_control_port) except Exception as e: log("[E] %s"%e) log("[E] Check if the control port is activated in /etc/tor/torrc") log("[E] Try to run as the same user as tor, i.e. sudo -u debian-tor ./torirc.py -s MY-CHAT (maybe useful or not) ") exit(0) s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) s.bind((hidden_service_interface,hidden_service_port)) log('[I] chat Server now Active') log('[I] Connect in order to chat typing the command "%s --connect=%s"'%(sys.argv[0],self.ts.hostname)) s.listen(5) t=Thread(target=self.serverRosterCleanThread,args=()) t.daemon=True t.start() while True: try: conn,addr=s.accept() cmsg=[] nick="anon_%d"%random.randint(0,10000) cmsg.append("Welcome %s, this is %s"%(nick,self.channelname)) self.servermsgs.append(cmsg) t=Thread(target=self.serverThread,args=(conn,addr,cmsg,nick)) t.daemon=True t.start() except KeyboardInterrupt: self.ts.disconnect() log("[I] (Main chat Server Thread): Exiting") exit(0) except: pass commands=[] def chat_help(): pass def chat_help(args): chantext.append("\ttor-IRC, %s %s"%(__author__,__date__)) chantext.append("\tCommands available:") for c in commands: chantext.append("\t\t/%s: %s"%(c[0],c[2])) return "" commands.append(("help",chat_help,"Local help")) def chat_server_help(args): return "/serverhelp" commands.append(("serverhelp",chat_server_help,"Request server commands help text")) def chat_quit(args): exit(0) commands.append(("quit",chat_quit,"Exit the python application 'TOR-IRC'")) count=0 cmdline="" inspoint=0 pagepoint=0 def changeSize(stdscr): global width,height size=stdscr.getmaxyx() width=size[1] height=size[0] def redraw(stdscr): global textpad global roster stdscr.clear() line=height-3 for i in reversed(range(len(chantext)-pagepoint)): try: stdscr.addstr(line,0,chantext[i],0) if line==0:break else:line-=1 except: pass for i in range(len(roster)): buddy=roster[i] stdscr.addstr(i,width-buddywidth+1,str(buddy),0) stdscr.hline(height-2,0,curses.ACS_HLINE,width) stdscr.vline(0,width-buddywidth,curses.ACS_VLINE,height-2) prompt="~ " stdscr.addstr(height-1,0,"%s%s"%(prompt,cmdline),0) stdscr.move(height-1,len(prompt)+inspoint) def processLine(command): if command.startswith("/"): comm=command[1:].split(' ') for t in commands: if comm[0].startswith(t[0]): func=t[1] return func(comm) return command def clientConnectionThread(stdscr,ServerOnionURL,msgs): global roster try: import socks except: print "[E] Cannot load socksiPy module." print "[E] Try installing python-socksiPy with package manager of your distro : pypi.python.org/pypi/SocksiPy " exit(0) while(True): try: log("Trying to connect to %s:%d"%(ServerOnionURL,hidden_service_port)) s=socks.socksocket(socket.AF_INET,socket.SOCK_STREAM) s.setproxy(socks.PROXY_TYPE_SOCKS5,tor_server,tor_server_socks_port) s.settimeout(100) s.connect((ServerOnionURL,hidden_service_port)) s.setblocking(0) log("clientConnection: Connected to %s"%ServerOnionURL) log("clientConnection: Autorequesting roster...") msgs.append("/roster") randomwait=random.randint(1,clientRandomWait) except: log("clientConnection: Cannot connect! retrying...") time.sleep(1) continue try: while(True): time.sleep(1) ready=select.select([s],[],[],1.0) if ready[0]: data=sanitize(s.recv(minimum_message_len)) if data.find("/PING ")>-1: continue if data.startswith("--roster"): roster=[] for i in data.split(' ')[1:]: roster.append(i) log(data) if len(msgs)>0: randomwait-=1 if randomwait==0: m=addpadding(msgs.pop(0)) s.sendall(m) randomwait=random.randint(1,clientRandomWait) if random.randint(0,clientRandomNoise)==0: ping="/PING " for i in range(120): ping+="%02X"%random.randint(0,255) msgs.append(ping) except: s.close() pass def clientMain(stdscr,ServerOnionURL): global cmdline global inspoint global pagepoint global width,height changeSize(stdscr) redraw(stdscr) msgs=[] t=Thread(target=clientConnectionThread,args=(stdscr,ServerOnionURL,msgs)) t.daemon=True t.start() while True: input=stdscr.getch() if(input==curses.KEY_RESIZE): changeSize(stdscr) if(input==curses.KEY_LEFT)and(inspoint>0): inspoint-=1 if(input==curses.KEY_RIGHT)and(inspoint<len(cmdline)): inspoint+=1 if(input==curses.KEY_BACKSPACE)and(inspoint>0): cmdline=cmdline[:inspoint-1]+cmdline[inspoint:] inspoint-=1 if(input==curses.KEY_DC)and(inspoint<len(cmdline)): cmdline=cmdline[:inspoint]+cmdline[inspoint+1:] if(input==curses.KEY_HOME): inspoint=0 if(input==curses.KEY_END): inspoint=len(cmdline) if(input==curses.KEY_PPAGE): pagepoint+=height-2 if len(chantext)-pagepoint<0: pagepoint=len(chantext) if(input==curses.KEY_NPAGE): pagepoint-=height-2 if pagepoint<0:pagepoint=0 # if (input == curses.KEY_UP): # if (input == curses.KEY_DOWN): if(input==10): tosend=processLine(cmdline) if len(tosend)>0: msgs.append(tosend) cmdline="" inspoint=0 if input>31 and input<128: if len(cmdline)<(width-5): cmdline=cmdline[:inspoint]+chr(input)+cmdline[inspoint:] inspoint+=1 redraw(stdscr) def Client(ServerOnionURL): global stdscr global STDOutLog STDOutLog=False try: stdscr=curses.initscr() curses.noecho() curses.cbreak() stdscr.keypad(1) clientMain(stdscr,ServerOnionURL) stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin() exit(0) except: stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin() if __name__=='__main__': parser=OptionParser() parser.add_option("-c","--connect",action="store",type="string",dest="connect" ,help="Acts as client, connect to a server") parser.add_option("-s","--server" ,action="store",type="string",dest="channel_name",help="Acts as server to some clients") if len(sys.argv)==1: parser.print_help() exit(0) (options,args)=parser.parse_args() if options.channel_name: s=Server() s.serverMain(options.channel_name) else: if len(options.connect)>0: Client(options.connect) else:parser.print_help()

[chan] 1984
Dec 12 03:31

save as py file ... works ! nice thanks !

[chan] account-sharing--everyone-benefits
Dec 12 03:34

its so small. where could a virus hide ? itz mostly the curses stuff. simple I/O as simple as fucking possible who cannot read this should stop programming and auditing

BM-2cXXe3MvH59AxkqVFru9EAhSaAx1p3AzX7
Dec 12 03:34

just logged on. this looks pretty cool. what server should I connect to?

[chan] general
Dec 12 03:37

read doc on release site run: torirc -s MYSERVER to launch own server for me to connect to torirc -c ibfkedkedbde.onion will connct as a client , if the server is really up. understood ?

[chan] general
BM-2cW67GEKkHGonXKZLCzouLLxnLym3azS8r

Subject Last Count
cp Jan 20 06:45 1
wtf Jan 20 05:11 2
Advertisement: MeinCoin Crypto Research Jan 20 01:03 1
Soviet ancient astronaut propaganda Jan 19 23:18 1
Security questions Jan 19 23:17 1
Cthulhu-Ancient Astronaut Connection Jan 19 23:17 1
I don't remember eating that! Jan 19 22:38 2
The Protocols of the Learned Elders of Zion Jan 19 21:41 2
Political Truth Jan 19 20:05 2
UK Column News - 19th January 2018 Jan 19 19:58 9
Wikileaks is a Front for Russian Intelligence Jan 19 19:58 2
UK Column News - 19th January 2018 Jan 19 19:58 5
It’s a coincidence … that Snowden got in contact with Wikileaks. Jan 19 19:58 2
- Dimitry Z. Manuilsky, Soviet Chairman of U.N. Security Council, 1949 Jan 19 19:58 2
From The Washington Times, 9/11/01: Jan 19 19:58 2
On Snowden and Coincidences Jan 19 19:58 2
What do we know about the new head of al-Qaeda, Ayman al-Zawahiri? Jan 19 19:58 2
Legacy Jan 19 19:58 4
From NTI, September 2001: Jan 19 19:58 2
From Aviation Week & Space Technology, 6/3/2002: Jan 19 19:58 2
Against the United States Jan 19 19:58 4
UK Column News - 19th January 2018 Jan 19 19:57 6
Active measures Jan 19 19:57 2
Or individual Jan 19 19:56 2
STFU why doncha: I'm sick of seeing this bollox continually reposted Jan 19 19:56 2
IDIOT(s) Jan 19 19:56 2
some jackass has copypasta syndrome Jan 19 19:56 2
chan Procedure Nazi Dumb Blonde SuperDick Jan 19 19:56 2
The Operating procedures of the alleged "many" are not dictated by the few Jan 19 19:56 2
Active measures Jan 19 19:55 2
More rejection of tribalism in the bible: Jan 19 19:54 8
God has been building his kingdom right under your nose and you can't see it! Jan 19 19:54 4
Stop quoting this old tribal stories of hope. We have a better God now. Jan 19 19:54 4
Jan 19 19:54 25
If the world hate you, ye know that it hated me before it hated you. Jan 19 19:54 4
You are a mental midget. Jan 19 19:54 4
John 7:7 Jan 19 19:54 4
But the Shepherd will return and destroy them. Jan 19 19:54 4
Just think how upset you will be when you find out that there is no god. Jan 19 19:54 7
Are there any Christians here or channels for Christian discussion? Jan 19 19:54 7
Christians Jan 19 19:54 9
You need urgent psychiatric help, dude. Jan 19 19:54 4
That's all you got? Ad hominem? Jan 19 19:54 4
> Quotes from my holy book I'm writing right now: Jan 19 19:54 1
You have the mental illness of religious mania. Jan 19 19:54 6
"The quick brown fox jumps over the lazy dog" (Joe Public 3:14) Jan 19 19:54 2
You hate your brother. You a heartless murderer. (John 8:44) Jan 19 19:54 4
The Greek New Testament rejected tribal distinctions: Jan 19 19:54 4
We are tired of your retarded crap. Jan 19 19:54 3
"Federal Government" means "Directing the mind of the flocks": Jan 19 19:54 4
John 15:18 Jan 19 19:54 4
Quotes from my holy book I'm writing right now: Jan 19 19:54 2
No, dude. Ad monkey. Jan 19 19:54 4
"Lorem ipsum dolor sit amet" (Jane Doe 6:66) Jan 19 19:54 2
Are you willing to die for your "holy book?" Jan 19 19:54 1
1 Corinthians 6:9-10 Jan 19 19:54 1
Are you willing to be crucified for your "holy book?" Jan 19 19:54 1
IAUZIA== Jan 19 18:38 1
farmapram@protonmail.com Jan 19 18:32 1
Eric Dubay: Dinosaurs Never Existed! Jan 19 18:19 4
Christians Jan 19 18:16 35
Dinosaurs! Jan 19 17:35 2
Customer complaint Jan 19 17:12 1
Richard Spencer's Anti-White Wife Jan 19 17:05 6
proximity Jan 19 16:36 2
enmity Jan 19 16:36 2
self-denial Jan 19 16:36 2
secret Jan 19 16:36 2
justification Jan 19 16:35 2
confession Jan 19 16:35 2
IPFS test Jan 19 15:55 10
force all connections through tor Jan 19 15:50 5
camlistore / perkeep Jan 19 14:27 1
argument heard Jan 19 11:54 1
(no subject) Jan 19 08:01 21
UK Column News - 18th January 2018 Jan 19 07:59 1
n00b Jan 19 04:37 16
to boldly go Jan 19 04:36 1
Updated Broadcast List (2017.12.25) Jan 19 02:00 2
Richard Spencer's Jewish Ancestry Jan 18 21:50 1
ALT RIGHT IS 1000% Jewish. Jan 18 21:37 1
face-id -> humanity sunset Jan 18 20:45 1
The UnaBomber was a psyop Jan 18 10:01 2
lucky boy Jan 18 08:58 10
The 411 on Charles Manson Jan 18 04:43 1
forbidden information & darknet directory assistance Jan 18 04:06 1
strong password Jan 18 00:08 5
Active measures (Russian: активные мероприятия) Jan 18 00:08 2
Hacking 101 Jan 18 00:08 2
UK Column News - 17th January 2018 Jan 18 00:08 7
Can Anyone Send Me A test Text to my Address? Jan 18 00:08 5
DDOS nuke response... Jan 18 00:08 3
Beat the NSA! Jan 18 00:08 16
Sattolo Latin Square Jan 18 00:08 7
Victim code Jan 17 19:18 1
Public announcement Jan 17 05:19 9
We are already at war: The most dangerous Libertarian in America Jan 17 01:13 1
[chan] 411 BM-2cW53MzWqtod8TA6vybdUeqd2LhTuXCX3L Jan 16 23:37 5
Suppose that a professor Jan 16 19:14 1
does anyone read here. Jan 16 19:06 10