• OOSocks
    279 replies, posted
Updated Linux and Windows. Update: And again!
Both of the bugs I mentioned (ReceiveLine returns instantly without data nor error when the socket is closed and sockets being handled outside of the Lua engine's knowledge) still exist in the latest build. I've also tried connecting to the socket using PuTTy with raw mode, and again no callbacks occur while the connection remains open.
[QUOTE=DfReisan;26927999]Both of the bugs I mentioned (ReceiveLine returns instantly without data nor error when the socket is closed and sockets being handled outside of the Lua engine's knowledge) still exist in the latest build. I've also tried connecting to the socket using PuTTy with raw mode, and again no callbacks occur while the connection remains open.[/QUOTE] Can you please show me an example of your code that replicates the bugs so I may test it.
[QUOTE=haza55;26929014]Can you please show me an example of your code that replicates the bugs so I may test it.[/QUOTE] Already did: [QUOTE=DfReisan;26774351]I've noticed an odd bug with the module, when the server closes the socket (socket:Close()), the client gets spammed with empty (data == "") ReceiveLine requests that have the errorcode of OK. I'm using this on the client: [lua] require("OOSocks") IP = "localhost" PORT = 1555 function clientsock_Callback(socket, callType, callId, err, data, peer, peerPort) if(err == SCKERR_CONNECTION_RESET) then print("[CLIENT] Disconnected.") end if( callType == SCKCALL_REC_LINE ) then print("[CLIENT] Received \"" .. data .. "\"" ) socket:ReceiveLine() end if( callType == SCKCALL_CONNECT && err == SCKERR_OK ) then socket:ReceiveLine() end end clientsock = OOSock( IPPROTO_TCP ) clientsock:SetCallback(clientsock_Callback) clientsock:Connect( IP, PORT ) [/lua] and this on the server: [lua] require("OOSocks") sockets = {} function clientsock_Callback(socket, callType, callId, err, data, peer, peerPort) if( callType == SCKCALL_REC_LINE ) then print( "[SERVER] Received \"" .. data .. "\"" ) socket:ReceiveLine() end end function serversock_Callback(socket, callType, callId, err, data, peer, peerPort) if( callType == SCKCALL_LISTEN && err == SCKERR_OK ) then print("[SERVER] Listening.") socket:Accept() end if(callType == SCKCALL_BIND && err == SCKERR_OK) then print("[SERVER] Socket Bound.") socket:Listen( 1 ) end if(callType == SCKCALL_ACCEPT) then print("[SERVER] Got a connection: "..peer) table.insert(sockets, data) data:SetCallback(clientsock_Callback) data:ReceiveLine() socket:Accept() end end serversock = OOSock( IPPROTO_TCP ) serversock:SetCallback(serversock_Callback) serversock:Bind( "", 1555 ) [/lua] Server's on the same machine as the client and it works fine, I can send and receive things, but when I close the socket on the server (lua_run for _,v in pairs(sockets) do v:Close() end), I get spammed with empty ReceiveLine callbacks on the client. I investigated this a bit and saw that you're using recvfrom in the module. recvfrom returns 0 (according to docs I've found on the net) when the socket is gracefully closed, and apparently this confuses the error check on the module or something. Please look into this. EDIT: Also, when using the Windows telnet client to connect to the server, the connection is accepted (although sometimes "randomly" drops) yet the accept callback isn't called.[/QUOTE] I also mentioned how I closed the socket, too. EDIT: Found another bug. When you try to connect to a location that's impossible to connect to, the game freezes for a few seconds and then returns without a callback being fired. Test code: [lua] require("oosocks") calltypes = { [0] = "CONNECT", [1] = "REC_SIZE", [2] = "REC_LINE", [3] = "SEND", [4] = "BIND", [5] = "ACCEPT", [6] = "LISTEN", [7] = "REC_DATAGRAM" } errors = { [0] = "OK", [1] = "NOT_CONNECTED", [2] = "CONNECTION_RESET", [3] = "TIMED_OUT", [4] = "BAD" } function SockCallback(socket, callType, callId, err, data, peer, peerPort) print("[CLIENT] Callback occured! ("..tostring(socket).." | "..tostring(calltypes[callType]).." | "..tostring(callId).." | "..tostring(errors[err]).." | "..tostring(data).." | "..tostring(peer)..")") end local sock = OOSock(IPPROTO_TCP) sock:SetCallback(SockCallback) sock:Connect( "42.0.0.1", 42 ) [/lua] Result: [code] ] lua_openscript_cl testsocket.lua Running script testsocket.lua... [/code] Expected result: [code] ] lua_openscript_cl testsocket.lua Running script testsocket.lua... [CLIENT] Callback occured! (*some socket object* | CONNECT | 1 | TIMED_OUT | | ) [/code] And finally, you might want to look into the curious case of BAD_CSTRING, I get that instead of an empty data argument when a callback of SEND is fired.
Is it just me, or is OOSocks much more buggy than the old luasocket module?
LuaSocket has been developed for 6 years. And this less than a year and with a different style. I think its quite good for the amount of time I've been able to spend on it.
How can I use this module to DoS servers?
[QUOTE=Godlike2;26996087]How can I use this module to DoS servers?[/QUOTE] Not enough throughput. You most likely can't unless you can find some exploit that eats the CPU instead of bandwidth.
Wtf.. How can I take down seths diamond build now?
[QUOTE=Godlike2;26996173]Wtf.. How can I take down seths diamond build now?[/QUOTE] Ask seth nicely to shut it down?
I'm having some problems. [lua]require( "oosocks" ) assert( OOSock, "oosocks is not installed" ) sourcequery = {} sourcequery.Queue = {} local TranslateDedicated = {} TranslateDedicated[ "l" ] = "Listen" TranslateDedicated[ "d" ] = "Dedicated" TranslateDedicated[ "p" ] = "SourceTV" local TranslateOS = {} TranslateOS[ "l" ] = "Linux" TranslateOS[ "w" ] = "Windows" function sourcequery.A2S_INFO( ip, port, callback ) sourcequery.Queue[ "A2S_INFO_" .. ip .. ":" .. port ] = callback local sock = OOSock( IPPROTO_UDP ) sock:SetBinaryMode( true ) sock:SetCallback( function( sock, call, id, err, bin, ip, port ) if ( err == SCKERR_OK ) then if ( call == SCKCALL_SEND ) then sock:ReceiveDatagram() elseif ( call == SCKCALL_REC_DATAGRAM ) then for i = 1, 4 do bin:ReadByte() end local server = {} server.IP = ip server.Port = port server.Type = bin:ReadByte() server.Version = bin:ReadByte() server.Name = bin:ReadString() server.Map = bin:ReadString() server.Directory = bin:ReadString() server.Game = bin:ReadString() server.AppID = bin:ReadByte() + bin:ReadByte() * 256 server.Players = bin:ReadByte() server.MaxPlayers = bin:ReadByte() server.Bots = bin:ReadByte() server.Dedicated = TranslateDedicated[ string.char( bin:ReadByte() ) ] or "Unknown" server.OS = TranslateOS[ string.char( bin:ReadByte() ) ] or "Unknown" server.Password = bin:ReadByte() server.Secure = bin:ReadByte() server.GameVersion = bin:ReadString() if ( sourcequery.Queue[ "A2S_INFO_" .. server.IP .. ":" .. port ] ) then sourcequery.Queue[ "A2S_INFO_" .. server.IP .. ":" .. port ]( server ) end end else print( "Something went terribly wrong!" ) end end ) sock:Send( "ÿÿÿÿTSource Engine Query\0", ip, port ) end[/lua] This code works perfectly in Windows. However, when I try to use it on my Linux server, it doesn't do anything at all. None of the callbacks are run. Am I doing something wrong or is this a bug? [editline]28th December 2010[/editline] After about 5 minutes of waiting, it worked. What the fuck. [editline]28th December 2010[/editline] Nevermind. I guess I was doing something wrong.
Was wondering would it be possible to use this to read/delete email? If so example connect code and so on please.
[code] 220 gw02.mail.redacted.xx ESMTP Postfix helo redacted.org 250 gw02.mail.redacted.xx MAIL TO:<redacted@hotmail.com> 501 5.5.4 Syntax: MAIL FROM:<address> MAIL FROM:<postmaster@redacted.org> 250 2.1.0 Ok RCPT TO:<redacted@hotmail.com> 250 2.1.5 Ok Subject: DERP 221 2.7.0 Error: I can break rules, too. Goodbye. [/code] I was trying to make example code but my ISP's SMTP server is rude :(
[QUOTE=Joeyl10;27042041][lua]local TranslateDedicated = {} TranslateDedicated[ "l" ] = "Listen" TranslateDedicated[ "d" ] = "Dedicated" TranslateDedicated[ "p" ] = "SourceTV" local TranslateOS = {} TranslateOS[ "l" ] = "Linux" TranslateOS[ "w" ] = "Windows" [/lua][/QUOTE] ugh.
[QUOTE=Python1320;27056498][code] 220 gw02.mail.redacted.xx ESMTP Postfix helo redacted.org 250 gw02.mail.redacted.xx MAIL TO:<redacted@hotmail.com> 501 5.5.4 Syntax: MAIL FROM:<address> MAIL FROM:<postmaster@redacted.org> 250 2.1.0 Ok RCPT TO:<redacted@hotmail.com> 250 2.1.5 Ok Subject: DERP 221 2.7.0 Error: I can break rules, too. Goodbye. [/code]I was trying to make example code but my ISP's SMTP server is rude :([/QUOTE] [del]Interesting, so any luck yet?[/del] Nvm, I can see your using SMTP, but I want to read an email. Not send one. I found the POP3 protocols anyways. :P
[QUOTE=Python1320;27056498][code] 220 gw02.mail.redacted.xx ESMTP Postfix helo redacted.org 250 gw02.mail.redacted.xx MAIL TO:<redacted@hotmail.com> 501 5.5.4 Syntax: MAIL FROM:<address> MAIL FROM:<postmaster@redacted.org> 250 2.1.0 Ok RCPT TO:<redacted@hotmail.com> 250 2.1.5 Ok Subject: DERP 221 2.7.0 Error: I can break rules, too. Goodbye. [/code] I was trying to make example code but my ISP's SMTP server is rude :([/QUOTE] Use wireshark to record a real transaction using Live Mail or Outlook.
[QUOTE=Python1320;27056498][code] 220 gw02.mail.redacted.xx ESMTP Postfix helo redacted.org 250 gw02.mail.redacted.xx MAIL TO:<redacted@hotmail.com> 501 5.5.4 Syntax: MAIL FROM:<address> MAIL FROM:<postmaster@redacted.org> 250 2.1.0 Ok RCPT TO:<redacted@hotmail.com> 250 2.1.5 Ok Subject: DERP 221 2.7.0 Error: I can break rules, too. Goodbye. [/code] I was trying to make example code but my ISP's SMTP server is rude :([/QUOTE] you probably need to send DATA before "Subject: DERP".
[QUOTE=deloc;27060034]ugh.[/QUOTE] I don't see a problem with that, why the groaning?
[QUOTE=Joeyl10;27067241]I don't see a problem with that, why the groaning?[/QUOTE] it's a pretty disgusting way of writing a table.
[QUOTE=deloc;27067540]it's a pretty disgusting way of writing a table.[/QUOTE] Would using something like [lua]{ l = "Linux", w = "Windows" }[/lua] be better then?
[QUOTE=deloc;27067540]it's a pretty disgusting way of writing a table.[/QUOTE] People have their own ways of writing code. It may make it easier for him to read the table that way (when coding, not running).
I love this module. :3 I got my server info printer done. [code] ] Print_Server_Info ***.***.***.*** Server Info: Port was not included. Defaulting to 27015. Server Info: Connecting to ***.***.***.*** on port 27015. Server Info: Receiving information. OS = Windows Port = 27015 Bots = 0 Players = 1 Directory = garrysmod GameVersion = 1.0.10.1 Map = gm_flatgrass Type = 73 Password = 0 AppID = 4000 Secure = 1 Version = 15 Dedicated = Listen MaxPlayers = 8 Game = [L] Sandbox Name = Bacon's TTT NIGGAS!!! IP = ***.***.***.*** Server Info: Retrieving challenge number for 'Bacon's TTT NIGGAS!!!'. Server Info: Receiving Challenge Number. Server Info: Challenge Number is 12730839. Server Info: Retieving players from 'Bacon's TTT NIGGAS!!!' with challenge number 12730839. Server Info: Receiving players. --------------------------------------------------------------------------------------------------------- |INDEX |NAME |SCORE |TIME | --------------------------------------------------------------------------------------------------------- |0 |Bakin' Bacon |0 |249 Mins | --------------------------------------------------------------------------------------------------------- [/code]hmm... for w=1,255 do for x=1,255 do for y=1,255 do for z=1,255 do RunConsoleCommand("Print_Server_Info",w.."."..x.."."..y.."."..z) end end end endXD
do want code
[QUOTE=Knallex;27149351]do want code[/QUOTE] Indeed, I made a server query script myself, it worked fine except for the players list query. Sometimes it worked fine, but mostly I just kept getting a (invalid?) challenge number every time I requested the players list.
[QUOTE=ali3n92;27152110]Indeed, I made a server query script myself, it worked fine except for the players list query. Sometimes it worked fine, but mostly I just kept getting a (invalid?) challenge number every time I requested the players list.[/QUOTE] I do see this too. It is weird, but I want to investigate it further before handing the code out. :3 And I want to remove all the debug messages.
Anyone tested the BinWrite on linux? I try to do [lua] b = BinWrite() b:WriteByte(0x31) b:WriteByte(0x03) b:WriteStringZeroTerminated( "0.0.0.0:0" ) b:WriteStringZeroTerminated( [[\gamedir\garrysmod\linux\1]] ) connection:Send(b, "hl2master.steampowered.com",27011) [/lua] with BinaryMode on but it just doesn't send anything. I tried to receive the message with netcat from linux srcds, but nothing is going through. SCKCALL_SEND is called but I receive no packets. Sending a string and setting binary mode off works though so unless the problem is above I don't know why it's failing.
Here's a full lua file for testing the above bug: [lua] timer.Simple(1,function() print"binding" require("oosocks") local Calltypes = { [SCKCALL_CONNECT] = "Connect", -- SCKCALL_CONNECT [SCKCALL_REC_SIZE] = "Rec Size", -- SCKCALL_REC_SIZE [SCKCALL_REC_LINE] = "Rec Line", -- SCKCALL_REC_LINE [SCKCALL_SEND] = "Send", -- SCKCALL_SEND [SCKCALL_BIND] = "Bind", -- SCKCALL_BIND [SCKCALL_ACCEPT] = "Accept", -- SCKCALL_ACCEPT [SCKCALL_LISTEN] = "Listen", -- SCKCALL_LISTEN [SCKCALL_REC_DATAGRAM] = "Datagram", -- SCKCALL_REC_DATAGRAM } local Errtypes = { [SCKERR_OK] = "Ok", -- SCKERR_OK [SCKERR_BAD] = "Bad", -- SCKERR_BAD [SCKERR_CONNECTION_RESET] = "Con Rest", -- SCKERR_CONNECTION_RESET [SCKERR_NOT_CONNECTED] = "Not Con", -- SCKERR_NOT_CONNECTED [SCKERR_TIMED_OUT] = "Timed Out", -- SCKERR_TIMED_OUT } if mssock then mssock:Close() end mssock = OOSock(IPPROTO_UDP); local MASTER_HOST = "hl2master.steampowered.com" mssock:SetCallback(function(socket, callType, callId, err, binread, peer, peerPort) --if(err != SCKERR_OK) then ErrorNoHalt(socket,": ",Calltypes[callType]," - ",Errtypes[err],"\n") --- socket:Close() --end if(callType == SCKCALL_BIND && err == SCKERR_OK) then local b = BinWrite() b:WriteStringZeroTerminated( [[test]] ) print("return:",socket:Send(b, "127.0.0.1", 3337)) socket:ReceiveDatagram(); end if(callType == SCKCALL_SEND && err == SCKERR_OK) then print("Sent."); end if(callType == SCKCALL_REC_DATAGRAM && err == SCKERR_OK) then local len= binread:GetSize() print("Got packet len="..len.." from " .. peer .. ":" .. tostring(peerPort)); socket:ReceiveDatagram(); end end); mssock:SetBinaryMode( true ) mssock:Bind("127.0.0.1", 12345) end) [/lua] Remember to join the server or write "bot" or the think hook won't run. I use netcat for listening: [code] C:\Users\iriz>nc -l -u 127.0.0.1 -p 3337 -vv listening on [any] 3337 ... [/code] [B]Also another bug:[/B] (using the same example code) Windows variation: [code] bot OOSock: 02A0E4B8: Bind - Ok return: 2 OOSock: 02A23678: Send - Ok Sent. lua_run mssock:Close() > mssock:Close()... OOSock: 02A5C4B8: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A0E478: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A545B8: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A611D8: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A5C4D8: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A5BA98: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A5DB98: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A56158: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A5E578: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A579F8: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A5AFD8: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A5C498: Datagram - Ok Got packet len=0 from 0.0.0.0:0 OOSock: 02A5EBB8: Datagram - Ok Got packet len=0 from 0.0.0.0:0 [/code] Linux variation: [code] > mssock:Close()... OOSock: 0x86f5a04: Datagram - Bad [/code]
When I have time(maybe in 2 weeks time), I want to rewrite the internals of this, keeping the same API.
I've been having troubles with this, whenever I run it on my local network it will work fine for a few minutes then a peer IP of 208.88.178.59 will show up (Not mine) and it will stop receiving on that server, the data shows up as [B][B]TSource Engine Query[/B] [/B] for that random IP.
Also had this new error: [IMG]http://i.imgur.com/RoLSA.png[/IMG]
Sorry, you need to Log In to post a reply to this thread.