From b88195721f6e315c6bc029a6936ba91e4733edd8 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 22 Apr 2013 15:17:15 +0200 Subject: update Reaktor - add color translator --- IRC/asybot.py | 8 ++++++-- IRC/index | 2 +- IRC/translate_colors.py | 31 +++++++++++++++++++++++++++++++ commands/whatweb | 6 +++--- repos/consolidate_dns/index | 5 +++-- repos/whatweb | 2 +- 6 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 IRC/translate_colors.py diff --git a/IRC/asybot.py b/IRC/asybot.py index df758ed..2cb533e 100755 --- a/IRC/asybot.py +++ b/IRC/asybot.py @@ -2,7 +2,7 @@ # # //Reaktor/IRC/asybot.py # - +from translate_colors import translate_colors def is_executable(x): import os return os.path.exists(x) and os.access(x, os.X_OK) @@ -24,6 +24,9 @@ formatter = logging.Formatter( '%(filename)s: %(levelname)s: %(message)s') hdlr.setFormatter(formatter) log.addHandler(hdlr) +# s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g -- removes color codes + + class asybot(asychat): def __init__(self, server, port, nickname, targets, **kwargs): asychat.__init__(self) @@ -110,6 +113,7 @@ class asybot(asychat): def PRIVMSG(text): for line in self.wrapper.wrap(text): msg = 'PRIVMSG %s :%s' % (','.join(params), line) + log.info(msg) self.push(msg) sleep(1) @@ -151,7 +155,7 @@ class asybot(asychat): return pid = p.pid for line in iter(p.stdout.readline,""): - PRIVMSG(line) + PRIVMSG(translate_colors(line)) log.debug('%s stdout: %s' % (pid, line)) p.wait() elapsed = time() - start diff --git a/IRC/index b/IRC/index index 50022ec..cc2652f 100755 --- a/IRC/index +++ b/IRC/index @@ -3,4 +3,4 @@ set -xeuf # cd //Reaktor cd $(dirname $(readlink -f $0))/.. -host=irc.freenode.net target='#krebsco' python IRC/asybot.py "$@" +host=irc.freenode.net target='#krebs' python IRC/asybot.py "$@" diff --git a/IRC/translate_colors.py b/IRC/translate_colors.py new file mode 100644 index 0000000..bd71661 --- /dev/null +++ b/IRC/translate_colors.py @@ -0,0 +1,31 @@ + + +COLOR_MAP = { + "\x1b[0m" : "\x0F", # reset + "\x1b[37m" : "\x0300", + "\x1b[30m" : "\x0301", + "\x1b[34m" : "\x0302", + "\x1b[32m" : "\x0303", + "\x1b[31m" : "\x0304", + "\x1b[33m" : "\x0305", + "\x1b[35m" : "\x0306", + "\x1b[33m" : "\x0307", + "\x1b[33m" : "\x0308", + "\x1b[32m" : "\x0309", + "\x1b[36m" : "\x0310", + "\x1b[36m" : "\x0311", + "\x1b[34m" : "\x0312", + "\x1b[31m" : "\x0313", + "\x1b[30m" : "\x0314", + "\x1b[37m" : "\x0315", + "\x1b[1m" : "\x02", # bold on + "\x1b[22m" : "\x02" # bold off + } +def translate_colors (line): + for color,replace in COLOR_MAP.items(): + line = line.replace(color,replace) + return line + +if __name__ == "__main__": + import sys + print (translate_colors(sys.stdin.read())) diff --git a/commands/whatweb b/commands/whatweb index 84130d5..afe2036 100755 --- a/commands/whatweb +++ b/commands/whatweb @@ -2,6 +2,6 @@ #wrapper for WhatWeb here=$(dirname `readlink -f $0`) whatweb_bin="$here/../repos/whatweb/whatweb" -[ -e "$whatweb_bin" ] || ( echo "!! Whatweb app does not exist" && exit 1 ) -[ "balls$1" = "balls" ] && ( echo "!! no host given" && exit 1) -exec $whatweb_bin -a 3 "$1" +[ ! -e "$whatweb_bin" ] && echo "!! Whatweb app does not exist" && exit 1 +[ -z "${1:-}" ] && echo "!! no host given" && exit 1 +exec $whatweb_bin -a 3 "$1" 2>&1 diff --git a/repos/consolidate_dns/index b/repos/consolidate_dns/index index 1a0dd81..3dd42fb 100755 --- a/repos/consolidate_dns/index +++ b/repos/consolidate_dns/index @@ -9,7 +9,7 @@ import tempfile os.chdir (os.path.dirname (os.path.realpath (sys.argv[0]))) dnsrecon_enabled = False DNSRECON = "../dnsrecon/dnsrecon.py" -dnsrecon_wordlist="namelist.txt" +dnsrecon_wordlist="../dnsrecon/namelist.txt" silent=open("/dev/null","w") gxfr_enabled = False GXFR = "../gxfr/gxfr.py" @@ -42,7 +42,8 @@ else: if dnsrecon_enabled: dnsrecon_tmp = tempfile.NamedTemporaryFile(delete=False).name print ("Starting dnsrecon, this may take some time") - p = Popen([DNSRECON,"-d",DOMAIN,"--csv",dnsrecon_tmp,'-D',dnsrecon_wordlist,"-t","brt,srv,axfr","--skip"],stdout=silent,stderr=silent) + #print (" ".join([DNSRECON,"-d",DOMAIN,"--csv",dnsrecon_tmp,'-D',dnsrecon_wordlist,"-t","brt,srv,axfr","--skip"])) + p = Popen([DNSRECON,"-d",DOMAIN,"--csv",dnsrecon_tmp,'-D',dnsrecon_wordlist,"-t","brt,srv,axfr"] ,stdout=silent,stderr=silent) p.wait() reader = csv.reader(open(dnsrecon_tmp)) for row in reader: diff --git a/repos/whatweb b/repos/whatweb index daab5f2..0918a0d 160000 --- a/repos/whatweb +++ b/repos/whatweb @@ -1 +1 @@ -Subproject commit daab5f21f13024ee8ec47e88f668c5308d6b59da +Subproject commit 0918a0d9b75df77f9c3e9eb360b6b22824582a20 -- cgit v1.2.3