^ A (CTRL + A) on the telnet client

0

I'm doing a telnet client in python and I need to send a code to another machine, but the code needs to put a Ctrl + A (CODE) ^A (code) does not work, heeelp me

serv = raw_input("[+] SERVER: ")
port = raw_input("[+] PORT: ")
tn = telnetlib.Telnet(serv, port)
mess = ("^AXXXX")
tn.write(mess)
out=tn.read_all()
print(out)
tn.close()
    
asked by anonymous 17.11.2018 / 06:32

1 answer

1
A is byte 1. You can test as follows:

import sys
print(sys.stdin.readline())

Run and type Ctrl + A and Enter

'\x01\n'

so to send it just send that character:

mess = "\x01XXXX"

or

mess = chr(1) + "XXXX"
    
17.11.2018 / 12:53