#!/usr/bin/env python
# Simple network
client
import socket;
import sys;
port = 31337; #
The port to listen on is hardcoded , if you bare changing this change the same
of the server
SIZE = 1000;
try :
host = sys.argv[1];
except : # Add localhost as the server if no host provided
host
= "127.0.0.1";
try :
sockfd = socket.socket(socket.AF_INET ,
socket.SOCK_STREAM);
except socket.error , e :
print "Error while Creating socket : ",e ;
sys.exit(1);
try :
sockfd.connect((host,port));
except
socket.gaierror , e :
print "Error (Address-Related) while
Connecting to server : ",e ;
except socket.error , e :
print "Error while Connecting to Server : ",e;
sys.exit(1);
# We are connected now , Start the real shit!
print("=============================================================");
print("\tSimple-CMD\tC0d3d by : 1i0n4n33sh");
print("=============================================================");
print("\t\tEmail : bharatg1666
@gmail.com");
print("=============================================================");
print("\tC0d3 f0r InDi4 , H4(k F0r 1nDi4 , Liv3 f0r 1nDi4");
print("=============================================================");
try :
while 1:
cmd = raw_input("\n\n(simple-cmd) $
");
sockfd.send(cmd);
result =
sockfd.recv(SIZE).strip();
if not len(result) :
fd.close();
sockfd.close();
break;
print(result);
except KeyboardInterrupt : #clean up code
sockfd.shutdown(0);
print("\n\n-------- Client Terminated
----------\n");
print("\n==================================================");
print("\tThanks for using Simple-CMD");
print("\tEmail : bharatg1666
@gmail.com");
print("====================================================\n\n");
No comments:
Post a Comment