-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathecho.py
More file actions
49 lines (41 loc) · 1.01 KB
/
echo.py
File metadata and controls
49 lines (41 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
'''
A simple echo client/server
example client:
echo.py localhost 8000
example server:
echo.py -l localhost 8000
'''
import argparse
import pync
def main():
parser = argparse.ArgumentParser('echo.py',
formatter_class=argparse.RawTextHelpFormatter,
description=__doc__,
)
parser.add_argument('dest',
help='Destination hostname or ip to connect or bind to',
nargs='?',
default='',
metavar='DEST',
)
parser.add_argument('port',
help='Port to connect or bind to',
metavar='PORT',
type=int,
)
parser.add_argument('-l',
help='Listen mode, for inbound connects',
action='store_true',
)
args = parser.parse_args()
nc = pync.Netcat(
dest=args.dest,
port=args.port,
l=args.l,
y='import sys; sys.stdout.write(sys.stdin.read())',
v=True,
)
nc.run()
if __name__ == '__main__':
main()