mirror of
https://github.com/onyx-and-iris/q3rcon-ps.git
synced 2025-01-18 08:40:52 +00:00
38 lines
826 B
PowerShell
38 lines
826 B
PowerShell
class Packet {
|
|
[System.Byte[]]$MAGIC = @(, 0xFF * 4)
|
|
|
|
[string] Header() {
|
|
throw "method not implemented"
|
|
}
|
|
}
|
|
|
|
class RequestPacket : Packet {
|
|
[string]$passwd
|
|
|
|
RequestPacket([string]$passwd) {
|
|
$this.passwd = $passwd
|
|
}
|
|
|
|
[System.Byte[]] Header() {
|
|
return $this.MAGIC + [System.Text.Encoding]::ASCII.GetBytes("rcon")
|
|
}
|
|
|
|
[System.Byte[]] Payload([string]$msg) {
|
|
return $this.Header() + [System.Text.Encoding]::ASCII.GetBytes($(" {0} {1}" -f $this.passwd, $msg))
|
|
}
|
|
}
|
|
|
|
class ResponsePacket : Packet {
|
|
[System.Byte[]] Header() {
|
|
return $this.MAGIC + [System.Text.Encoding]::ASCII.GetBytes("print\n")
|
|
}
|
|
}
|
|
|
|
Function New-RequestPacket([string]$passwd) {
|
|
[RequestPacket]::new($passwd)
|
|
}
|
|
|
|
Function New-ResponsePacket {
|
|
[ResponsePacket]::new()
|
|
}
|