Skip to content
Browse files

template support added

  • Loading branch information...
1 parent 2dc7f56 commit 442331144ce14080bb8f5c9238c5fe049daa815c @mastahyeti mastahyeti committed
View
0 example_dicts/example_client_dict → example_files/example_client_dict
File renamed without changes.
View
0 example_dicts/example_dictionary → example_files/example_dictionary
File renamed without changes.
View
0 example_dicts/example_server_dict → example_files/example_server_dict
File renamed without changes.
View
37 httpshell.coffee
@@ -5,6 +5,8 @@ program = require './includes/commander.js'
#Default Options
client_dict = ['hello','world']
server_dict = ['hello','world']
+client_template = '##$$##'
+server_template = '##$$##'
port = 80
host = "127.0.0.1"
delay = 1000 #time between connections
@@ -33,10 +35,13 @@ printconfig = ->
console.log "delay : #{delay}"
console.log "password : #{password}"
console.log "client dictionary: #{client_dict}"
- console.log "server dictionary: #{server_dict}\n"
+ console.log "server dictionary: #{server_dict}"
+ console.log "client template : \n#{client_template}"
+ console.log "server template : \n#{server_template}\n"
parseconfig = =>
#Should we shut up?
+ #console.log program
if program.quiet?
console.log = (string) ->
return
@@ -56,11 +61,15 @@ parseconfig = =>
#Parse the client dictionary file argument
if program.clientdict?
client_dict = readbyline program.clientdict
-
#Parse the server dictionary file argument
if program.serverdict?
server_dict = readbyline program.serverdict
-
+ #Read the client template file
+ if program.clienttemplate?
+ client_template = fs.readFileSync program.clienttemplate, 'utf8'
+ #Read the server template file
+ if program.servertemplate?
+ server_template = fs.readFileSync program.servertemplate, 'utf8'
#Help Message / Description...
helpme = \
@@ -90,14 +99,16 @@ helpme = \
#Setup the options parsing
program
.version('0.0.2')
- .option('-h --host [address]',"Server IP address or domain name [#{host}](Client/Server)",host)
- .option('-p --port [port]',"Server listening port [#{port}] (Client/Server)",port)
- .option('-d --delay [delay-ms]',"Miliseconds to delay between requests [#{delay}](Client only)",delay)
- .option('-s --secret [shared]',"Shared secret to use for aes192 encryption [#{password}](Client/Server)",password)
- .option('-a --dict <filename>','Path to the dictionary file to use for both client and server (Client/Server)')
- .option('-b --clientdict <filename>','Path to the dictionary to use for client communication (Client/Server)')
- .option('-c --serverdict <filename>','Path to the dictionary to use for server communication (Client/Server)')
- .option('-q --quiet','Run quietly. (Client only)')
+ .option('-a --host [address]',"Server IP address or domain name [#{host}](Client/Server)",host)
+ .option('-b --port [port]',"Server listening port [#{port}] (Client/Server)",port)
+ .option('-c --delay [delay-ms]',"Miliseconds to delay between requests [#{delay}](Client only)",delay)
+ .option('-e --secret [shared]',"Shared secret to use for aes192 encryption [#{password}](Client/Server)",password)
+ .option('-f --dict <filename>','Path to the dictionary file to use for both client and server (Client/Server)')
+ .option('-g --clientdict <filename>','Path to the dictionary to use for client communication (Client/Server)')
+ .option('-h --serverdict <filename>','Path to the dictionary to use for server communication (Client/Server)')
+ .option('-i --clienttemplate <filename>','Path to the template file to use for client communication (Client/Server)')
+ .option('-k --servertemplate <filename>','Path to the template file to use for server communication (Client/Server)')
+ .option('-l --quiet','Run quietly. (Client only)')
program
.command('server')
@@ -105,7 +116,7 @@ program
.action =>
parseconfig()
printconfig()
- server host,port,delay,password,client_dict,server_dict
+ server host,port,delay,password,client_dict,server_dict,client_template,server_template
program
.command('client')
@@ -113,7 +124,7 @@ program
.action =>
parseconfig()
printconfig()
- client host,port,delay,password,client_dict,server_dict
+ client host,port,delay,password,client_dict,server_dict,client_template,server_template
program.on '--help', ->
console.log helpme
View
12 includes/reverse_shell.coffee
@@ -3,11 +3,11 @@ http = require 'http'
{transcoder} = require './transcoder'
class exports.server
- constructor: (@host,@port,@delay,@password,@client_dict,@server_dict)->
+ constructor: (@host,@port,@delay,@password,@client_dict,@server_dict,@client_template,@server_template)->
console.log "Running as server\n"
#setup transcoders
- @ct = new transcoder @client_dict, @password
- @st = new transcoder @server_dict, @password
+ @ct = new transcoder @client_dict, @password, @client_template
+ @st = new transcoder @server_dict, @password, @client_template
@to_client = ''
@@ -46,11 +46,11 @@ class exports.server
class exports.client
- constructor: (@host,@port,@delay,@password,@client_dict,@server_dict)->
+ constructor: (@host,@port,@delay,@password,@client_dict,@server_dict,@client_template,@server_template)->
console.log "Running as client\n"
#setup transcoders
- @ct = new transcoder @client_dict, @password
- @st = new transcoder @server_dict, @password
+ @ct = new transcoder @client_dict, @password, @client_template
+ @st = new transcoder @server_dict, @password, @client_template
@to_return = ""
#Spawn a shell as a subprocess
View
7 includes/transcoder.coffee
@@ -8,7 +8,7 @@ of integers of base x and then build an output string from the
dictionary elements corresponding to these indexes.
'''
class exports.transcoder
- constructor: (@dict,@password) ->
+ constructor: (@dict,@password,@template) ->
#base of the input string. We assume UTF8 for now.
@stringbase = 256
#Output base will be determined by num of elts in dict
@@ -18,12 +18,15 @@ class exports.transcoder
encode: (string) ->
#encode the string
- @a2s(@string_to_basex(@encrypt(string)))
+ @templatize(@a2s(@string_to_basex(@encrypt(string))))
decode: (string) ->
#decode the string
@decrypt(@basex_to_string(@s2a(string)))
+ templatize: (string) ->
+ @template.replace '##$$##',string
+
a2s: (array) ->
#Convert array of dict indexes to a string
str = (@dict[i] for i in array).join(' ')

0 comments on commit 4423311

Please sign in to comment.
Something went wrong with that request. Please try again.