d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Abducts Code Dump
Add Reply New Topic New Poll
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 30 2013 04:09pm
been a way a while. got unbanned time to post some shit ive been working on.

Simple chat server with admin and profile support.

Protocol
Code
client -> server
(byte)     header      \xFF
(byte)     packet id   \x50
(byte)     protocol id \x00
(ntstring) username
(ntstring) password

server -> client
(byte)     header          \xFF
(byte)     packet id       \x50
(byte)     response code
            \x00 good login
            \x01 bad protocol id
            \x02 ip banned
            \x03 invalid password
            \x04 empty credentials
            \x05 already logged in
(ntstring) response string

---------------------------------------------------

Client -> server
(byte)     header      \xFF
(byte)     packet id   \x51
(byte)     chat event  
            \x01 get userlist    (*)
            \x04 whisper         (**)
            \x06 talk
            \x07 emote
(ntstring) text

* : can omit the text field along with null terminator
**: must include username as first word of text

server -> client
(byte)     header      \xFF
(byte)     packet id   \x51
(byte)     chat event  
            \x01 userlist (**)
            \x02 user join
            \x03 user left
            \x04 whisper
            \x05 whisper comfirm
            \x06 talk (*)
            \x07 emote
*: (ntstring) username
(ntstring) text

**: userlist is sent as a single string dilimited by space

---------------------------------------------------

Client -> server
(byte)         header      \xFF
(byte)         packet id   \x3A
(byte)         admin event  
                \x01 kill username    (*)
                \x02 ip ban           (*)
                \x03 remove ip ban    (*)
                \x04 set flags        (**)
                \x05 remove flags     (**)
                \x06 find flags       (*)
                \x07 change pass      (**)
                \x08 request userdata (*)
* : (ntstring) username/ip
**: (ntstring) username
   (ntstring) flags/passwod

Server -> client
(byte)     header      \xFF
(byte)     packet id   \x3A
(byte)     admin event
            \x00 denied
            \x01 kill username confirm
            \x02 ip ban confirm
            \x03 remove ip ban confrim
            \x04 set flags confirm
            \x05 remove flags confirm
            \x06 find flags confirm
            \x07 change pass confirm
            \x08 userdata confirm
(ntstring) confirmation text

---------------------------------------------------

Client -> server
(byte)          header      \xFF
(byte)          packet id   \x1C
(byte)          admin event  
                 \x01 set user profile      (*)
                 \x02 retrieve user profile (**)
* :  (ntstring) age
    (ntstring) description
    (ntstring) profile
**:  (ntstring) username

Server -> client
(byte)          header      \xFF
(byte)          packet id   \x1C
(byte)          admin event  
                 \x01 confirm set user profile
                 \x02 confirm retrieve user profile
(ntstring) response


Server.rb
http://pastebin.com/V0Zeg1DL

PacketParser.rb
http://pastebin.com/eLGh1rwP

PacketReciever.rb
http://pastebin.com/pcWtppZf

PacketSender.rb
http://pastebin.com/Gs4vB0y7

UserHandler.rb
http://pastebin.com/wGMXq5yE
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 30 2013 04:13pm
Galaxy Empire crawling bot.

This was for a mobile game I reversed for android. Its protocol consisted of

json -> aes 256 -> base64 -> gzip

what this does is crawls all the galaxies and systems in the game collecting player stats and positions which is supposed to remain anonymous so people have to hunt each other down.

http://pastebin.com/KaKPr2rj

i have also created a bot for this which allows me to lookup players stats from in game and have them mailed to my account. next project is full automation of the game but i have other things to do atm.

This post was edited by AbDuCt on Jun 30 2013 04:16pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 30 2013 04:23pm
Satoko.rb

this is a axel wrapper that will crawl a http file directory and parse it for downloadable content and feed the links to axel back to back.

has a file directory listing to tell you which files are completed. outputs download speed from axel directly, and has a hacked on resume function.

usage: ruby satoko.rb "directory to download" <integer>

the integer tells the crawler how many files to skip before feeding it to axel, in case axel dies and you have to restart.

beware, this works but the code is a complete mess.

Code
require 'net/http'
require 'uri'
require 'cgi'
require 'pty'

def print_table( table )
listing = 0
length = 0

 table.each do |file|
   next if file.empty?
     length = file[:name].length unless length > file[:name].length
   end

table_width = ENV['COLUMNS'].to_i / (length + 30)

format = "%-#{length}s"

 table.each do |file|
   next if file.empty?
   print "[*] File: "
   print format % file[:name]
   print " -> Completed: %-#{3}s" % file[:complete]

   if listing.eql? table_width
     print "\n"
     listing = 0
   else
     print "    "
     listing += 1
   end
 end
end

def uri_escape( uri )
URI.escape uri
uri.gsub! "]", "%5D"
uri.gsub! "[", "%5B"
end

#################################################################
#################################################################
#################################################################

exit unless ARGV.length > 0

url   = 'http://www.petfo.net/dds/'
anime = uri_escape ARGV[0]
filenum = ARGV[1].to_i unless ARGV[1].empty?
files = []

uri      = URI.parse("#{url}#{anime}/".strip)
http     = Net::HTTP.new( uri.host, uri.port )
request  = Net::HTTP::Get.new( uri.request_uri )

puts 'Grabbing file listings...'
response = http.request(request)

response.body.each_line do |line|
 arr = line.scan /(".*?")/
 next if arr.empty? or arr.last.include? "\"/dds/\"" or arr.last.include? "\"-//W3C//DTD HTML 3.2 Final//EN\""
 name =  arr.last.to_s[4..-5]
 hash = {:name => CGI.unescape(name), :url => URI.unescape("#{url}#{anime}/#{name}"), :complete => "No"}
 files.push hash
end

files.push "" unless files.length.modulo(2).eql? 0
anime = URI.unescape(anime)
1.upto(filenum) { files.shift } if filenum.is_a? Fixnum

puts 'Grabbed file listings!'
puts 'Starting downloads in 3 seconds...'
sleep 3

files.each_index do |index|
 begin
   PTY.spawn "axel -n 12 \"#{files[index][:url]}\"" do |stdout, stdin, pid|
     begin
       stdout.each do |line|
         next unless line.include? "["
         puts "\e[H\e[2J"
         print_table files
         puts "\n\n"
         puts "Server: #{url}"
         puts "Anime: #{anime}"
         puts "Current file: #{files[index][:name]}"
         puts "\n"
         puts line
       end
     rescue Errno::EIO
     end
   end
 rescue PTY::ChildExited
 end

 files[index][:complete] = "Yes"
end
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 30 2013 04:26pm
passwordcracker.rb

this code shows the algro to increment a string to find the next password to check against. this is a pure bruteforce method for plaintext passwords and holds no real purpose.

Code
require 'benchmark'

class PasswordCracker
 def initialize( password )
   @password_to_crack = password
   @password_hash = {}
 end
 
 def getnextpassword( current_password )
   current_password.each_index do |index|
     if( current_password[index] >= 126 )
       current_password[index] = 33
     else
       break if( current_password[index] == 126 )
         current_password[index] += 1
       break
     end
   end
     result = ''
     current_password.each { |item| result += item.chr }
     result
 end
 
 def crackpassword
   starting_password = []
   next_password = ''
   @password_to_crack.each_char { starting_password.push '!'.ord }
   time = Benchmark.realtime do
     while next_password != @password_to_crack do
       next_password = getnextpassword starting_password
     end
   end
   time
 end
end


test = PasswordCracker.new "!!!~"
puts "took #{test.crackpassword} seconds to crack the password"
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jun 30 2013 05:03pm
welcome back
Member
Posts: 3,386
Joined: May 4 2013
Gold: 1,780.00
Jun 30 2013 05:16pm
Code

[22] pry(main)> Benchmark.measure{
[22] pry(main)*   500000.times{ |i|
[22] pry(main)*     getnextpassword [100, 100, 100]
[22] pry(main)*   }  
[22] pry(main)* }  
=>   1.050000   0.000000   1.050000 (  1.056252)

[23] pry(main)> Benchmark.measure{
[23] pry(main)*   500000.times{ |i|
[23] pry(main)*     "ddd".next
[23] pry(main)*   }  
[23] pry(main)* }  
=>   0.220000   0.000000   0.220000 (  0.222358)


bad news ;)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Jun 30 2013 05:24pm
Quote (nuvo @ Jun 30 2013 07:16pm)
Code
[22] pry(main)> Benchmark.measure{
[22] pry(main)*   500000.times{ |i|
[22] pry(main)*     getnextpassword [100, 100, 100]
[22] pry(main)*   }  
[22] pry(main)* }  
=>   1.050000   0.000000   1.050000 (  1.056252)

[23] pry(main)> Benchmark.measure{
[23] pry(main)*   500000.times{ |i|
[23] pry(main)*     "ddd".next
[23] pry(main)*   }  
[23] pry(main)* }  
=>   0.220000   0.000000   0.220000 (  0.222358)


bad news ;)


well i know i could of used next, but i was trying to create something that could be remade into other languages. <3

your code doesnt support keyspace ranges. if i would completely remove checks for keyspace and such i be i would get close to the same results.

This post was edited by AbDuCt on Jun 30 2013 05:37pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll