Esempio n. 1
0
     def connect(s):
          """ Establish a connection with the RE atlas. """
          s._setup_socket();
          s._socket.connect((s.host,s.port));
          # Shake hands with server
          msg, closed = netutils.readall(s._socket,11);
          if (closed):
               raise ConnectionError("Could not connect to RE atlas server. ");
          if (msg != "REatlas" + struct.pack('!l',s._protocol_version)):
               if (msg[0] == SRV_MSG):
                    lenrest = netutils.ntohll(msg[1:9]);
                    msg2,closed = netutils.readall(s._socket,lenrest-2);
                    msg = msg[9:] + msg2
                    s.disconnect();
                    raise ConnectionError("Received error message from server: " + msg);
               else:
                    s.disconnect();
                    raise ConnectionError("Bad handshake from server or unsupported server version.");
          try:
               s._socket.sendall(netutils.htonl(428344082)); # Send our handshake to the server
          except socket.error:
               s.disconnect();
               raise ConnectionError("Could not connect to RE atlas server.");

          s._is_connected = True;
          s._request_count = 0;
Esempio n. 2
0
#!/usr/bin/python

import reatlas_client
import netutils

atlas = reatlas_client.REatlas("localhost",65535);

atlas.connect();
atlas.build_functions();
#print(atlas.login(username="******",password="******"));
#print(atlas._get_available_methods());
#print(atlas._select_current_file(filename="test"))

atlas._socket.sendall(reatlas_client.BIN_REQUEST + netutils.htonll(0));

packtype = atlas._socket.recv(1);
l = netutils.ntohll(atlas._socket.recv(8));

print("Type: " + str(netutils.ntohb(packtype)) + " (" + packtype + ")");
print("Length: " + str(l));
print(atlas._socket.recv(l));



atlas.disconnect();

Esempio n. 3
0
atlas = reatlas_client.REatlas("localhost",65535);

atlas.connect();
atlas.build_functions();
print(atlas.login(username="******",password="******"));
print(atlas._get_available_methods());
print(atlas._select_current_file(filename="test"))

message = "HESTEHEST ! ! ! ! ! ! ! !"

atlas._socket.sendall(reatlas_client.BIN_FILE + netutils.htonll(len(message)));

atlas._socket.sendall(message);


packtype, closed = netutils.readall(atlas._socket,1);
l,closed = netutils.readall(atlas._socket,8);
l = netutils.ntohll(l);

#if (len(packtype) == 1 and len(l) == 8):
if True:
     print("Type: " + str(netutils.ntohb(packtype)) + " (" + packtype + ")");
     print("Length: " + str(l));
     if (l > 0):
          print(atlas._socket.recv(l));



atlas.disconnect();