Skip to content

Instantly share code, notes, and snippets.

@wingo
Last active August 29, 2015 14:03
Show Gist options
  • Save wingo/5f820a5fadfd327af09c to your computer and use it in GitHub Desktop.
Save wingo/5f820a5fadfd327af09c to your computer and use it in GitHub Desktop.
tcp port 80
return function(P,length)
if not 24 <= length then return false end
local v1 = P:u16(12)
if not v1 == 2048 then goto L2 end
local v2 = P:u8(23)
if not v2 == 6 then return false end
if v2 == 6 then goto L4 end
if v2 == 17 then goto L4 end
if not v2 == 132 then return false end
::L4::
local v3 = P:u16(20)
local v4 = bit.band(v3,8191)
if not v4 == 0 then return false end
local v5 = P:u8(14)
local v6 = bit.band(v5,15)
local v7 = bit.lshift(v6,2)
local v8 = v7+16
if not v8 <= length then return false end
local v9 = v7+14
local v10 = P:u16(v9)
if v10 == 80 then return true end
local v11 = v7+18
if not v11 <= length then return false end
local v12 = P:u16(v8)
do return v12 == 80 end
::L2::
if not 56 <= length then return false end
if not v1 == 34525 then return false end
local v13 = P:u8(20)
if v13 == 6 then goto L8 end
if not v13 == 44 then return false end
local v14 = P:u8(54)
if not v14 == 6 then return false end
::L8::
if not v1 == 34525 then return false end
local v15 = P:u8(20)
if v15 == 6 then goto L12 end
if not v15 == 44 then goto L12 end
local v16 = P:u8(54)
if not v16 == 6 then goto L12 end
::L12::
local v17 = P:u16(54)
if v17 == 80 then return true end
if not 58 <= length then return false end
local v18 = P:u16(56)
do return v18 == 80 end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment