Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- ==IMPORTANT (Update July 20th 2017)==
- PLEASE WATCH THIS VIDEO IF YOU'RE SETTING UP
- https://youtu.be/1JshIC6_6w4
- DO NOT USE THE STEPS BELOW IF YOU'RE USING HTTPS XAT, OTHERWISE GO AHEAD.
- =====================================
- MAJOR NOTE: FIREFOX 51+ WILL NOT WORK WITH THIS ANYMORE!
- A packet editor focused on sending, receiving, reading or modifying packets
- between you and Xat.
- Copyright (c) 2016 Daniel. S. (Majora) [ [email protected] ]
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the "Software"), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or
- sell copies of the Software, and to permit persons to whom
- the Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- =end
- #= Important Note =#
- =begin
- Before you run the program, you should set your PAC file
- for your browser to be "https://shadow19.xyz/proxy",
- if you do not know how to install a PAC file
- goto http://findproxyforurl.com/deploying-pac/
- and read under the "Browser Deployment"
- section.
- Download the custom crossdomain.xml
- http://pastebin.com/raw/1e7fDinF
- or make you're own.
- make sure the name of the file is "crossdomain.xml"
- and is in the same folder as the program.
- Then you should go and install ruby on
- your system, so you can run the program.
- Windows: http://rubyinstaller.org/downloads/
- Mac, Unix, Linux: https://www.ruby-lang.org/en/documentation/installation/#package-management-systems
- PS: I'm not going to help anyone, so don't ask please, thank you.
- If you don't understand this, then it is over your head.
- PS PS: If you want to use a custom swf for the chat,
- use "https://shadow19.xyz/proxy?custom"
- for your PAC options instead, then
- paste your swf to the directory of
- the program, make sure its name is
- like "chatXXXd.swf", "chatXXX.swf" or just "chat.swf".
- =end
- #= End =#
- ["socket","eat","json","cgi","zlib"].each do |lib|
- begin
- require lib
- rescue LoadError
- system("gem install #{lib}")
- Gem.clear_paths
- retry
- end
- end
- #= Options =#
- $cache_iprules = true #Set to false temporarily if you get weird glitches on xat (likes friends list not being functional)
- $cache_static = true
- $logging = true
- $inchat_logging = false
- $super_chat = [true, "PRIVATE"]
- #= End =#
- #= Catching the useless verbose =#
- class HTTPClient::SSLConfig
- def warn(*a)
- ""
- end
- end
- class WebAgent::Cookie
- def warn(*a)
- ""
- end
- end
- class NilClass
- def split(*a)
- ""
- end
- def length(*a)
- 0
- end
- end
- #= End =#
- class String
- def getAttr(attribute)
- return self[/#{attribute}=\"(.*?)\"/,1]
- end
- def setAttr(attribute, value)
- return self.gsub!(/#{attribute}=\"[^\"]*?\"/,"#{attribute}=\"#{value}\"")
- end
- def tag?(tagname)
- return self[/<(.*?)[\s+|\/>]/,1] == tagname
- end
- def tag
- return self[/<(.*?)[\s+|\/>]/,1]
- end
- end
- def deepCopy(obj)
- return Marshal.load(Marshal.dump(obj))
- end
- def csum(str)
- str = str.to_s
- return Zlib::crc32(str)
- end
- def windows?
- return (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
- end
- def mac?
- return (/darwin/ =~ RUBY_PLATFORM) != nil
- end
- def unix?
- return !windows?
- end
- def linux?
- return unix? if !mac?
- end
- def loadFilters(decoy=false)
- Dir.mkdir("filters") unless File.directory?("filters")
- path = File.expand_path(File.dirname(__FILE__))
- if !decoy
- Thread.main["filters"] = {}
- Dir["#{path}/filters/*.rb"].each do |filter|
- Thread.main["filters"][filter[filter.rindex("/")+1..-1]] = File.binread(filter)
- end
- elsif decoy.class == Thread
- decoy["filters"] = {}
- Dir["#{path}/filters/*.rb"].each do |filter|
- decoy["filters"][filter[filter.rindex("/")+1..-1]] = File.binread(filter)
- end
- end
- end
- def filter(data, direction, decoy)
- if direction == ">"
- if data.getAttr("t")
- command = data.getAttr("t").strip.split(" ")
- command[0].delete!("^[a-zA-Z0-9\/]")
- if decoy["done"]
- if command[0][0..1] == "//"
- command[0] = command[0][2..-1]
- if command[0] == "decoy" && command[1] == "die"
- exit()
- end
- if command[0] == "decoy" && command[1] == "unload" && command[2] != "all"
- decoy["filters"] = {}
- decoy["parent"]["filters"] = {} if decoy["parent"]
- decoy["child"]["filters"] = {} if decoy["child"]
- decoy["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"Filters have been unloaded.",
- "u"=>"0"
- }
- }
- )
- )
- return false
- end
- if command[0] == "decoy" && command[1] == "unload" && command[2] == "all"
- Thread.main["filters"] = {}
- Thread.main["connected"].keys.each do |dec|
- dec = Thread.main["connected"][dec]
- if dec
- dec[3]["filters"] = {}
- dec[2]["filters"] = {}
- end
- end
- decoy["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"All filters have been unloaded.",
- "u"=>"0"
- }
- }
- )
- )
- return false
- end
- if command[0] == "decoy" && command[1] == "reload" && command[2] != "all"
- loadFilters(decoy)
- loadFilters(decoy["parent"]) if decoy["parent"]
- loadFilters(decoy["child"]) if decoy["child"]
- decoy["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"Filters have been reloaded.",
- "u"=>"0"
- }
- }
- )
- )
- return false
- end
- if command[0] == "decoy" && command[1] == "reload" && command[2] == "all"
- loadFilters(false)
- Thread.main["connected"].keys.each do |dec|
- dec = Thread.main["connected"][dec]
- if dec
- loadFilters(dec[3])
- loadFilters(dec[2])
- end
- end
- decoy["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"All filters have been reloaded.",
- "u"=>"0"
- }
- }
- )
- )
- return false
- end
- end
- end
- end
- end
- backup_data = deepCopy(data)
- decoy["filters"].keys.each do |file|
- begin
- eval(decoy["filters"][file])
- rescue Exception
- puts "Error occured in #{file}"
- data = backup_data
- end
- end
- return data
- end
- def packet(*object)
- return object.collect{|object|"<#{object.keys[0].to_s.gsub(/\W/,"")} #{object[object.keys[0]].keys.collect{|attribute|"#{attribute.to_s.gsub(/\W/,"")}=\"#{object[object.keys[0]][attribute].to_s.gsub("\"",""").gsub(">","\xCB\x83").gsub("<","<")}\""}.join(" ")} />\x00"}.join
- end
- def getId(username)
- if Thread.main["cache"]
- return Thread.main["cache"]["grid#{username}"] if Thread.main["cache"]["grid#{username}"]
- end
- error = false
- data = eat("http://xat.me/web_gear/chat/profile.php?name=#{username.delete("^[a-zA-Z0-9]")}") rescue error = true
- return data != "" && !error ? (Thread.main["cache"]["grid#{username}"]=data) : (Thread.main["cache"]["grid#{username}"]=username)
- end
- def getUsername(id)
- if Thread.main["cache"]
- return Thread.main["cache"]["grun#{id}"] if Thread.main["cache"]["grun#{id}"]
- end
- error = false
- data = eat("http://xat.me/web_gear/chat/profile.php?id=#{id.delete("^[0-9]")}") rescue error = true
- return data != "" && !error ? (Thread.main["cache"]["grun#{id}"]=data) : (Thread.main["cache"]["grun#{id}"]=id)
- end
- def getRoomId(chatname)
- if Thread.main["cache"]
- return Thread.main["cache"]["gri#{chatname}"] if Thread.main["cache"]["gri#{chatname}"]
- end
- error = false
- data = eat("http://xat.com/web_gear/chat/roomid.php?d=#{chatname.delete("^[a-zA-Z0-9_]")}") rescue error = true
- return data != "-10-110" && !error ? (Thread.main["cache"]["gri#{chatname}"]=data) : (Thread.main["cache"]["gri#{chatname}"]=chatname) if Thread.main["cache"]
- return data != "-10-110" && !error ? data : chatname
- end
- def getRoomName(id)
- return Thread.main["cache"]["grn#{id}"] if Thread.main["cache"]["grn#{id}"] if Thread.main["cache"]
- error = false
- data = eat("http://xat.com/x?id=#{id.delete("^[0-9]")}")[/\<meta property=\"og:url\" content=\"(.*?)\" \/>/,1][/\/\/xat.com\/(.*)/,1] rescue error = true
- return data != "" && !error ? (Thread.main["cache"]["grn#{id}"]=data) : (Thread.main["cache"]["grn#{id}"]=id) if Thread.main["cache"]
- return data != "" && !error ? data : id
- end
- def iprules(startup)
- if File.file?("ip2.txt") and File.file?("ip2.txt.expire") and $cache_iprules
- if File.mtime("ip2.txt").to_i >= File.read("ip2.txt.expire").to_i
- Thread.main["iprules_original"] = JSON.parse(eat("http://xat.com/web_gear/chat/ip2.php"))
- Thread.main["iprules"] = deepCopy(Thread.main["iprules_original"])
- Thread.main["iprules"]["E1"] = Thread.main["iprules"]["E0"] = [1,["127.0.0.1:456:1"]]
- File.write("ip2.txt",JSON.pretty_generate(Thread.main["iprules_original"]))
- File.write("ip2.txt.expire",(Time.now.to_i+300))
- elsif startup
- Thread.main["iprules_original"] = JSON.parse(File.read("ip2.txt"))
- Thread.main["iprules"] = deepCopy(Thread.main["iprules_original"])
- Thread.main["iprules"]["E1"] = Thread.main["iprules"]["E0"] = [1,["127.0.0.1:456:1"]]
- end
- end
- if startup
- if !File.file?("ip2.txt") or !File.file?("ip2.txt.expire") or !$cache_iprules
- Thread.main["iprules_original"] = JSON.parse(eat("http://xat.com/web_gear/chat/ip2.php"))
- Thread.main["iprules"] = deepCopy(Thread.main["iprules_original"])
- Thread.main["iprules"]["E1"] = Thread.main["iprules"]["E0"] = [1,["127.0.0.1:456:1"]]
- File.write("ip2.txt",JSON.pretty_generate(Thread.main["iprules_original"])) if $cache_iprules
- File.write("ip2.txt.expire",(Time.now.to_i+300)) if $cache_iprules
- end
- end
- Thread.main["attempt"] = 0
- Thread.main["prevrpool"] = -1
- end
- def xhttp(d, e=1800, t="text/html")
- return %{HTTP/1.1 200 OK\r\nDate: #{Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT")}\r\nContent-Type: #{t}\r\nContent-Length: #{d.length}\r\nConnection: keep-alive\r\nCache-Control: max-age=#{e}\r\nServer: cloudflare-nginx\r\n\r\n}.lstrip + d
- end
- def connected?()
- return (!!`ping #{windows? ? "-n" : "-c"} 1 8.8.8.8`[/ttl/i]) rescue false
- end
- def connect(host, port, timeout=false)
- addr = Socket.getaddrinfo(host, nil)
- sock = Socket.new(Socket.const_get(addr[0][0]),Socket::SOCK_STREAM,0)
- if timeout
- secs = timeout.to_i
- usecs = ((timeout-secs)*1000000).to_i
- timeout = [secs,usecs].pack("l_2")
- sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_RCVTIMEO,timeout)
- sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_SNDTIMEO,timeout)
- end
- sock.connect(Socket.pack_sockaddr_in(port, addr[0][3]))
- return sock
- end
- #= Ported from network.as =#
- def xdom(room) #roomid
- return rand(0..3) if Thread.main["iprules"]["xFlag"] & 8 == 8
- return 0 if room.to_i == 8
- return room.to_i < 8 ? 3 : (room.to_i & 96) >> 5
- end
- def xport(room) #roomid
- return 10007 + rand(0..31) if Thread.main["iprules"]["xFlag"] & 8 == 8
- return 10000 if room.to_i == 8
- return room.to_i < 8 ? 9999 + room.to_i : 10007 + room.to_i % 32
- end
- def xroom(roomname) #roomname, returns roomid
- return eat("http://xat.com/web_gear/chat/roomid.php?d=#{roomname.downcase.gsub(/[^\w_]/,"")}")
- end
- def pickip(room) #roomid, returns ip, port, timeout
- Thread.main["attempt"] = Thread.main["attempt"] % 4
- Thread.main["attempt"] += 1
- a = b = c = d = f = g = h = nil
- h = Thread.main["iprules_original"]["order"][Thread.main["attempt"]][0]
- i = Thread.main["iprules_original"][h]
- j = Thread.main["iprules_original"]["order"][Thread.main["attempt"]][1]
- if i[0] & 1 == 1
- a = 0
- if Thread.main["prevrpool"] == -1
- a = rand(1..(i.length-1))
- else
- a = ((a % (i.length - 1)) + 1)
- end
- b = rand(0..(i[a].length-1))
- c = i[a][b].split(":")
- c[1] = 10000 if !c[1]
- c[2] = 39 if !c[2]
- d = c[1].to_i + rand(0..c[2].to_i-1)
- Thread.main["prevrpool"] = a
- a = b = c[1] = c[2] = f = g = h = i = nil
- return [c[0],d,j]
- end
- e = xdom(room)
- f = xport(room)
- g = i[1][rand((4 * e)..3)]
- a = b = c = d = h = i = nil
- return [g,f,j]
- end
- #= End =#
- #= Globals =#
- Thread.main["cdp"] = File.binread("crossdomain.xml")
- Thread.main["connected"] = {}
- Thread.main["logging"] = $logging
- Thread.main["icl"] = $inchat_logging
- Thread.main["cache"] = {} if $cache_static
- Thread.main["filters"] = {}
- Thread.main["active_chat"] = ($super_chat.class == Array ? $super_chat[0] : $super_chat) ? "" : false
- Thread.main["super_chat_mode"] = $super_chat.class == Array ? ($super_chat[1].strip.downcase == "private" ? 1 : $super_chat[1].strip.downcase == "main" ? 2 : $super_chat[1].strip.downcase == "both" ? 3 : 0) : 3
- #= End =#
- #Initialize
- if windows?
- system("title Decoy Packet Editor")
- system("cls")
- elsif mac?
- system("echo -n -e \"\033]0;Decoy Packet Editor\007\"")
- system("clear")
- elsif unix? or linux?
- system("PS1=$; unset PROMPT_COMMAND")
- system("echo -ne \"\033]0;Decoy Packet Editor\007\"")
- system("clear")
- end
- iprules(true)
- loadFilters(false)
- begin
- Thread.main["middle"] = TCPServer.new("127.0.0.1",456)
- rescue Exception
- puts "Error occured in creating the local server,"
- puts "please make sure decoy is not running already"
- puts "or check if the port \"456\" is being used"
- puts "by another program, or if your network"
- puts "is working properly."
- sleep(3)
- exit()
- end
- puts "Decoy Packet Editor is now ready!"
- Thread.new do
- loop do
- Thread.start(Thread.main["middle"].accept) do |client| #parent
- Thread.current["<"] = client
- Thread.current["done"] = false
- Thread.current["afix"] = nil
- Thread.current["ping"] = Time.now.to_i
- loadFilters(Thread.current)
- while data = Thread.current["<"].recv(16384)
- if !data or data == ""
- print(Thread.current["roomname"] ? "Disconnected from #{Thread.current["roomname"]}.\n" : "")
- Thread.current["afix"] = nil
- Thread.current["<"].close rescue break
- Thread.current[">"].close rescue break
- break
- end
- if data[0] != "<" or data[-3..-1] != "/>\x00"
- Thread.current["afix"] = nil
- Thread.current["<"].close rescue break
- Thread.current[">"].close rescue break
- break
- end
- #Sorting the packets individually
- data.split(/(?<=\x00)/).each do |data|
- #Send crafted crossdomain policy.
- if data.tag?("policy-file-request")
- puts "[<] #{data}".inspect[1..-2] if Thread.main["logging"]
- Thread.current["<"].print "#{Thread.main["cdp"]}\x00"
- #Check for y initialization packet
- elsif data.tag?("y") and data.getAttr("r")
- #Check if connection is hanging after y initialization
- Thread.current["_y"] = Thread.new(Thread.current){|y| sleep(1.5); y["<"].close; y[">"].close}
- #Identifying what chat the thread is on.
- Thread.current["uid"] = data.getAttr("u")
- Thread.current["room"] = data.getAttr("r")
- Thread.main["active_chat"] = data.getAttr("r") if Thread.main["active_chat"]
- Thread.current["roomname"] = getRoomName(data.getAttr("r"))
- puts "[#{Thread.current["roomname"]}][>] #{data}".inspect[1..-2] if Thread.main["logging"]
- #Kill old duplicate connections/threads
- if Thread.main["connected"][data.getAttr("r")]
- Thread.main["connected"][data.getAttr("r")][0].close rescue puts("INPUT SOCKET FAILED TO CLOSE")
- Thread.main["connected"][data.getAttr("r")][1].close rescue puts("OUTPUT SOCKET FAILED TO CLOSE")
- Thread.main["connected"][data.getAttr("r")][2].kill rescue puts("OLD INPUT DUPLICATE THREAD FAILED TO DIE")
- Thread.main["connected"][data.getAttr("r")][3].kill rescue puts("OLD OUTPUT DUPLICATE THREAD FAILED TO DIE")
- Thread.main["connected"].delete(data.getAttr("r"))
- end
- info = pickip(data.getAttr("r"))
- #Choose IP like client does it
- Thread.current[">"] = connect(info[0], xport(data.getAttr("r")), info[2])
- Thread.current[">"].print data
- Thread.current["child"] = Thread.new do
- loadFilters(Thread.current)
- Thread.current["BUFFER"] = ""
- Thread.current[">"] = Thread.current["parent"][">"]
- Thread.current["<"] = Thread.current["parent"]["<"]
- Thread.current["uid"] = Thread.current["parent"]["uid"]
- Thread.current["room"] = Thread.current["parent"]["room"]
- Thread.current["roomname"] = Thread.current["parent"]["roomname"]
- begin
- while data = Thread.current[">"].recv(16384) and !Thread.current[">"].closed?
- #Connection isn't hanging, so we kill the hang check
- Thread.current["parent"]["_y"].kill
- if !data or data == ""
- Thread.current["parent"]["afix"] = nil
- Thread.current[">"].close rescue break
- break
- end
- #Buffer partitioned data
- if data[-3..-1] != "/>\x00"
- Thread.current["BUFFER"] += data
- next
- elsif Thread.current["BUFFER"] != ""
- Thread.current["BUFFER"] += data
- data = Thread.current["BUFFER"]
- Thread.current["BUFFER"] = ""
- end
- #Check for valid xml
- if data[0] != "<" or data[-3..-1] != "/>\x00"
- Thread.current["parent"]["afix"] = nil
- Thread.current[">"].close rescue break
- break
- end
- #Sorting the packets individually
- data.split(/(?<=\x00)/).each do |data|
- if data.tag?("done")
- Thread.current["done"] = Thread.current["parent"]["done"] = true
- Thread.current["<"].print(
- packet(
- {
- "m"=>{
- "t"=>"Decoy Packet Editor is running!",
- "u"=>"0"
- }
- }
- )
- )
- end
- # Super Chat
- if Thread.main["active_chat"] and Thread.current["done"] and ["m","p"].index(data.tag) and data.getAttr("t")
- if (Thread.main["super_chat_mode"] == 1 and data.tag?("p")) or (Thread.main["super_chat_mode"] == 2 and data.tag?("m")) or (Thread.main["super_chat_mode"] == 3 and ["m","p"].index(data.tag))
- if !["/"].index(data.getAttr("t")[0]) and Thread.current["room"] != Thread.main["active_chat"]
- begin
- Thread.main["connected"][Thread.main["active_chat"]][0].print(
- packet(
- {
- "m"=>{
- "t"=>"[#{Thread.current["roomname"]}]#{["z","p"].index(data.tag) ? "[Private]" : ""}[#{getUsername(data.getAttr("u")[/(.+)[_]/,1]||data.getAttr("u"))}] #{data.getAttr("t")}",
- "u"=>Thread.current["uid"],
- "i"=>"0"
- }
- }
- )
- )
- rescue Exception
- end
- end
- end
- end
- # ~ Super Chat End
- if Thread.current["done"] and Thread.main["icl"]
- begin
- Thread.current["<"].print(
- packet(
- {
- "z"=>{
- "t"=>"[<] #{data.gsub("#"," _# ").gsub("\""," " ").inspect[1..-6]}",
- "u"=>Thread.current["uid"],
- "d"=>Thread.current["uid"],
- "s"=>"2"
- }
- }
- )
- )
- rescue Exception
- end
- end
- data = filter(data,"<",Thread.current)
- next if data == false
- puts "[#{Thread.current["roomname"]}][<] #{data}".inspect[1..-2] if Thread.main["logging"] #Input
- Thread.current["<"].print data#From middle
- end
- end
- rescue
- Thread.current["<"].close rescue puts("INPUT SOCKET FAILED TO CLOSE")
- Thread.current[">"].close rescue puts("OUTPUT SOCKET FAILED TO CLOSE")
- Thread.current["parent"].kill rescue puts("OLD OUTPUT DUPLICATE THREAD FAILED TO DIE")
- Thread.current.kill rescue puts("OLD INPUT DUPLICATE THREAD FAILED TO DIE")
- end
- end#Child
- Thread.current["child"]["parent"] = Thread.current
- Thread.main["connected"][data.getAttr("r")] = [Thread.current["<"],Thread.current[">"],Thread.current["child"],Thread.current]
- else#Master tag check
- # Super Chat Check
- if ["f","z","m","p","c"].index(data.tag) and Thread.main["active_chat"]
- if data.getAttr("t")
- if !data.getAttr("t")["/KD"] and !data.getAttr("t")["/KEEPALIVE"] and !data.getAttr("t")["/away"] and !data.getAttr("t")["/a"]
- Thread.main["active_chat"] = Thread.current["room"]
- end
- else
- Thread.main["active_chat"] = Thread.current["room"]
- end
- end
- # ~ Super Chat Check End
- next if Thread.current["afix"] == data and !data.tag?("f")
- Thread.current["afix"] = data
- if Thread.current["done"] and Thread.main["icl"]
- begin
- Thread.current["<"].print(
- packet(
- {
- "z"=>{
- "t"=>"[>] #{data.gsub("#"," _# ").gsub("\""," " ").inspect[1..-6]}",
- "u"=>Thread.current["uid"],
- "d"=>Thread.current["uid"],
- "s"=>"2"
- }
- }
- )
- )
- rescue Exception
- end
- end
- data = filter(data,">",Thread.current)
- next if data == false
- puts "[#{Thread.current["roomname"]}][>] #{data}".inspect[1..-2] if Thread.main["logging"] #Output
- Thread.current[">"].print data #To middle
- end
- end#Sorting packets
- end#Socket data collection
- end#Accepting Thread
- end#Loop
- end#Thread
- #local-only webserver to serve crafted GET responses
- #Note: Can also do other requests if you want to.
- Thread.main["proxy"] = TCPServer.open("localhost",1000)
- loop do
- client = Thread.main["proxy"].accept
- data = client.recv(4096)
- #Scan for valid GET
- get = data[/GET\s*(.*?)\s*HTTP\/1.(0\r\n|1\r\n|0\n|1\n)/,1]
- if get
- if get[/ip2.php$/]
- iprules(false)
- client.puts xhttp(JSON.generate(Thread.main["iprules"]),1800,"text/html")
- elsif get[/chat.*swf\?.*$/]
- swfn = Dir["cha*.swf"][0]
- if swfn
- swf = File.binread(swfn)
- client.puts(xhttp(swf,180,"application/x-shockwave-flash"))
- else
- swf = eat(get.gsub(/chat([0-9]{3}).swf/,"chat\\1d.swf"))
- File.binwrite("chat.swf",swf)
- client.puts(xhttp(swf,180,"application/x-shockwave-flash"))
- end
- end
- end
- client.close
- end
Advertisement
Add Comment
Please, Sign In to add comment