-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpySeFi.py
More file actions
75 lines (67 loc) · 1.71 KB
/
pySeFi.py
File metadata and controls
75 lines (67 loc) · 1.71 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# =============================
# Author --> devMen
# Date created --> 01/04/2021
# Last modified --> 05/04/2021
# Version --> Python 3.8.5
# =============================
"""
|Python File Sender|
programa simple para enviar archivos
"""
# =============================
# Imports
import socket
import sys
import time
import argparse
# =============================
def banner():
return """
___ ___ ___ _
| _ \_ _/ __| ___| __(_)
| _/ || \__ \/ -_) _|| |
|_| \_, |___/\___|_| |_|
|__/
===> by ☆ developmentMen☆
"""
def enviar(s, filename):
s.send(filename.encode())
time.sleep(1)
file = open(filename, 'rb')
while True:
strng = file.readline(512)
if not strng:
break
s.send(strng)
file.close()
print("archivo enviado con exito")
def main():
s = socket.socket()
s.connect((args.ipAddress, args.port))
enviar(s, args.file)
s.close()
if __name__=='__main__':
argumentos = argparse.ArgumentParser(
description="Python file sender")
g = argumentos.add_mutually_exclusive_group()
g.add_argument('-nb', '--noBanner', action='store_true',
help="no print banner")
argumentos.add_argument(
'-i', '--ipAddress', type=str, required=True, metavar="",
help="ip PySeFi Server")
argumentos.add_argument(
'-p', '--port', type=int, metavar='',
default=6333, help='Port 1024 to 65535 -> default=6333')
argumentos.add_argument(
'-f', '--file', type=str, required=True, metavar="",
help="file to send")
args = argumentos.parse_args()
if not args.noBanner: print(banner())
try:
main()
except Exception as e:
print('=======ERROR======ERROR=======ERROR=======')
print(e)
print('=======ERROR======ERROR=======ERROR=======')