Skip to content

Instantly share code, notes, and snippets.

@SamP20
Created November 3, 2018 09:02
Show Gist options
  • Save SamP20/1546d086a0864e5b7638f62f23354ea7 to your computer and use it in GitHub Desktop.
Save SamP20/1546d086a0864e5b7638f62f23354ea7 to your computer and use it in GitHub Desktop.
Windows 10 ssh-agent test
from asyncssh.packet import *
from base64 import b64encode
SSH_AGENTC_REQUEST_IDENTITIES = 11
SSH_AGENT_IDENTITIES_ANSWER = 12
def main():
f = open(r"\\.\pipe\openssh-ssh-agent", 'r+b', 0)
payload = Byte(SSH_AGENTC_REQUEST_IDENTITIES)
f.write(UInt32(len(payload)) + payload)
f.seek(0)
resplen = int.from_bytes(f.read(4), 'big')
resp = f.read(resplen)
resp = SSHPacket(resp)
resptype = resp.get_byte()
assert (resptype==SSH_AGENT_IDENTITIES_ANSWER), "Incorrect response type"
numkeys = resp.get_uint32()
for _ in range(numkeys):
key_blob = resp.get_string()
comment = resp.get_string()
print(comment)
packet = SSHPacket(key_blob)
algorithm = packet.get_string()
print(algorithm)
encoded_blob = b64encode(key_blob)
print(encoded_blob)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment