echo_send.py (1363B)
1 #!/usr/bin/env python3 2 # Copyright (c) 2017-2021 Ivan Jelincic <parazyd@dyne.org> 3 # 4 # This file is part of tor-dam 5 # 6 # This program is free software: you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation, either version 3 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program. If not, see <https://www.gnu.org/licenses/>. 18 19 from argparse import ArgumentParser 20 from socket import socket, AF_INET, SOCK_STREAM 21 22 import socks 23 24 parser = ArgumentParser() 25 parser.add_argument('-a', '--address', default='some.onion') 26 parser.add_argument('-p', '--port', default=5000) 27 parser.add_argument('-t', '--tor', default='127.0.0.1:9050') 28 args = parser.parse_args() 29 30 if '.onion' in args.address: 31 s = socks.socksocket(AF_INET, SOCK_STREAM) 32 s.set_proxy(socks.SOCKS5, args.tor.split()[0], int(args.tor.split()[1])) 33 else: 34 s = socket(AF_INET, SOCK_STREAM) 35 36 s.connect((args.address, args.port)) 37 s.send(b'HELLO') 38 data = s.recv(1024) 39 s.close() 40 41 print(data)