torIRC mini ver.

[chan] 1st amendment
Dec 12 03:21 [raw]

#!/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 [raw]

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

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

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 [raw]

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

[chan] general
Dec 12 03:37 [raw]

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
A8D8AD21C55A29E05DB003218D7DB6D5 Apr 26 18:50 1
E59CBFBAA52D4DC07A3BB9D0F0BFF976 Apr 26 16:01 6
In need of muliplatform commandline file encryption tool Apr 26 16:01 65
What academia calls 'overkill' actually comes nearer true security Apr 26 15:50 7
About Python Apr 26 15:45 5
E874EB3A371EF948BAC6A30E79956C30 Apr 26 14:12 1
Active measures (Russian: активные мероприятия) Apr 26 12:07 6
Disconnect your Windows from NSA Apr 26 12:06 7
UK Column News - 25th April 2018 Apr 26 12:06 2
What We Don't Know about Children Apr 26 08:10 1
Help. Lost address of onion chatroulette. Apr 25 23:00 5
You can tell it's real because it looks so fake. Apr 25 20:59 1
INSURGENTILE BROADCAST Apr 25 20:55 1
Mars looks a lot like Greenland Apr 25 20:55 4
NASA Faked Mars Landings Apr 25 20:55 1
The results Apr 25 20:14 4
Your own Apr 25 20:14 3
739D64C6E385B7F30EECC281752786E2 Apr 25 20:05 2
UK Column News - 24th April 2018 Apr 25 11:20 2
I am Apr 25 11:18 3
tender age Apr 25 11:16 2
I have Apr 25 11:14 2
Basel, Switzerland is seat of NWO Apr 25 08:55 2
PM Apr 25 08:36 7
bicycle accident Apr 25 08:33 1
dough Apr 25 08:09 1
snoregillfibits Apr 25 08:03 1
doudouche Apr 25 08:02 1
gelernte Apr 25 08:02 1
Jesus the Nazaretan had frequent sexual relationships Apr 25 08:00 3
NSA is what's left of the pre-communist American establishment Apr 25 07:44 2
Moon Craters Debunked 100% Proof Apr 25 07:31 9
war is peace. slavery is freedom. Apr 25 06:43 1
So I was messing around with the Danwin webchat today.. Apr 24 18:45 1
CAE873004F632F1076801E565B0FEE54 Apr 24 11:53 1
UK Column News - 23rd April 2018 Apr 24 11:41 2
White background Apr 24 07:30 1
Dread forums compromised? Apr 24 04:35 2
Outer Space Photos are Fake. Apr 24 01:25 4
Where is bleep from bittorrent? Apr 24 00:26 5
Khazar = Caesar = Kaizer = Czar Apr 23 22:24 1
Synagogue of satan Apr 23 22:18 2
Collaborative blog Apr 23 22:12 4
A3FE399F592CD587F60710E78DA341D5 Apr 23 22:11 2
Mass insanity. Apr 23 21:31 3
D78292FC07D22F2979F904D76417E1FA Apr 23 17:28 1
Gun Control Is Bull Apr 23 10:43 12
DARKNET DIRECTORY ASSISTANCE Apr 23 09:18 1
The Fake Truth Movement (Shills) Exposed Apr 23 09:01 1
Neil Degrasse Tyson's Teaching Method Apr 23 08:39 2
100 Percent proof we can't orbit earth. Debunk This. Apr 23 08:36 2
Relaxing In Her Panties Apr 23 08:21 1
Obama's lovechild Apr 23 07:18 3
INFOWARS IS A COVERT U.S. MILITARY PSYCHOLOGICAL WARFARE OPERATION Apr 23 07:18 1
Glucklich Geburtstag Apr 23 06:27 6
UK Column News Apr 23 06:04 1
Zionist-curated civil war in America Apr 23 05:23 1
CIA Produces Child Porn Apr 23 05:02 1
PUTTING TO REST FAKE SATELLITES USING HALE TELESCOPE by Captain Obvious Apr 23 03:14 1
IMPOSSIBALL Apr 23 02:29 1
Episode 332 - The Weaponization of Social Media Apr 23 02:04 1
The Holocaust in Serbia Apr 23 01:55 1
Women who seek to be equal with men lack ambition. — Marilyn Monroe Apr 23 01:55 1
Justice for Gary Yarbrough Apr 23 01:49 1
The political and commercial morals of the United States are not merely food for laughter, they are an entire banquet. — Mark Twain Apr 23 01:28 1
Body Language: Mark Zuckerburg Apr 23 01:14 1
The Web began dying in 2014, here's how Apr 23 01:09 1
King of the North - Ottoman Empire Apr 23 01:08 1
Sage of Quay Radio Hour: Sofia Smallstorm – Assange, WikiLeaks and Beyond AI Apr 23 00:43 1
[chan] 411 BM-2cW53MzWqtod8TA6vybdUeqd2LhTuXCX3L Apr 23 00:39 1
TRO LLC Apr 23 00:14 1
Feds busted onin site Apr 23 00:10 4
23B5A151168ADE38BA27F697E42C26BA Apr 23 00:08 3
http://pastagdsp33j7aoq.onion/freak-least-pig/raw/gpg4usb.txt Apr 22 17:01 1
332C3DE1D432848E7D3FF16E476AE90D Apr 22 16:06 1
Anagrams for U.S. Apr 22 08:57 11
(no subject) Apr 22 08:53 14
Muslims attack St. Catherine Monastery police checkpoint Apr 22 08:43 2
WWDD: On Real NSA Whistleblowing Apr 22 08:30 1
PedoGate: Top Army General Charged With Multiple Counts of Child Rape Apr 22 07:59 1
The Largest Cult in the world: GNU/GPL Apr 22 07:54 2
Did the NSA ‘create’ Satoshi Nakamoto? Apr 22 07:54 1
To the President of the United States of America Apr 22 07:27 2
Egypt: A Christian boy was murdered "by Islamic extremists hoping to intimidate Christians Apr 22 07:24 2
XMPP Server Apr 22 07:16 2
MELANIA IS A MAN---UFACTURED WOMAN 100 PC Apr 22 07:14 1
Report Pedophiles to Authorities Apr 22 06:37 10
AA9A4CE1409AEFA893E2F114AA078345 Apr 22 05:54 1
Free XMPP Server Apr 21 16:33 19
5649C10A577B686C3C7EB0DBC4047E29 Apr 21 14:31 1
27FAA5B0508629A54CD8E950CDCA13ED Apr 21 03:51 1
C236ED2692DFC5028F480B20DF28AEAA Apr 20 20:34 1
Acronyms for NT ??? Apr 20 17:08 11
C2C6B15FFEB9719A8153767C70D06240 Apr 20 15:53 1
Become a Programmer, Mother Fucker Apr 20 15:02 1
Ending White Slavery Apr 20 14:21 2
E5768CE2C26B0A7E1D827A325E96E05B Apr 20 13:18 1
▌│█║▌║▌║ Chaos Management: So You Wanna be a Nazi ║▌║▌║█│▌ Apr 20 05:41 1
ephue Apr 20 05:08 2
Satellites Are Fake - Just Another NASA Hoax Apr 20 01:46 10