mirror of
https://github.com/maxDcb/C2TeamServer
synced 2026-06-06 16:14:27 +00:00
Add ListenerGithub
This commit is contained in:
+43
-16
@@ -114,10 +114,16 @@ class Listeners(QWidget):
|
||||
|
||||
# send message for adding a listener
|
||||
def addListener(self, message):
|
||||
listener = TeamServerApi_pb2.Listener(
|
||||
type=message[0],
|
||||
ip=message[1],
|
||||
port=int(message[2]))
|
||||
if message[0]=="github":
|
||||
listener = TeamServerApi_pb2.Listener(
|
||||
type=message[0],
|
||||
project=message[1],
|
||||
token=message[2])
|
||||
else:
|
||||
listener = TeamServerApi_pb2.Listener(
|
||||
type=message[0],
|
||||
ip=message[1],
|
||||
port=int(message[2]))
|
||||
self.grpcClient.addListener(listener)
|
||||
|
||||
# send message for stoping a listener
|
||||
@@ -155,8 +161,10 @@ class Listeners(QWidget):
|
||||
# add
|
||||
# if listener is not yet already on our list
|
||||
if not inStore:
|
||||
self.listListenerObject.append(Listener(self.idListener,
|
||||
listener.listenerHash, listener.type, listener.ip, listener.port, listener.numberOfSession))
|
||||
if listener.type == "github":
|
||||
self.listListenerObject.append(Listener(self.idListener, listener.listenerHash, listener.type, listener.project, listener.token[0:10], listener.numberOfSession))
|
||||
else:
|
||||
self.listListenerObject.append(Listener(self.idListener, listener.listenerHash, listener.type, listener.ip, listener.port, listener.numberOfSession))
|
||||
self.idListener = self.idListener+1
|
||||
|
||||
self.printListeners()
|
||||
@@ -186,16 +194,19 @@ class CreateListner(QWidget):
|
||||
|
||||
layout = QFormLayout()
|
||||
self.labelType = QLabel("Type")
|
||||
self.type = QLineEdit()
|
||||
self.qcombo = QComboBox(self)
|
||||
self.qcombo.addItems(["http" , "https" , "tcp" , "github"])
|
||||
self.qcombo.currentTextChanged.connect(self.changeLabels)
|
||||
self.type = self.qcombo
|
||||
layout.addRow(self.labelType, self.type)
|
||||
|
||||
self.labelIP = QLabel("IP")
|
||||
self.ip = QLineEdit()
|
||||
layout.addRow(self.labelIP, self.ip)
|
||||
self.param1 = QLineEdit()
|
||||
layout.addRow(self.labelIP, self.param1)
|
||||
|
||||
self.labelPort = QLabel("Port")
|
||||
self.port = QLineEdit()
|
||||
layout.addRow(self.labelPort, self.port)
|
||||
self.param2 = QLineEdit()
|
||||
layout.addRow(self.labelPort, self.param2)
|
||||
|
||||
self.buttonOk = QPushButton('&OK', clicked=self.checkAndSend)
|
||||
layout.addRow(self.buttonOk)
|
||||
@@ -203,12 +214,28 @@ class CreateListner(QWidget):
|
||||
self.setLayout(layout)
|
||||
self.setWindowTitle("Input Dialog demo")
|
||||
|
||||
def checkAndSend(self):
|
||||
type = self.type.text()
|
||||
ip = self.ip.text()
|
||||
port = self.port.text()
|
||||
|
||||
result = [type, ip, port]
|
||||
def changeLabels(self):
|
||||
if self.qcombo.currentText() == "http":
|
||||
self.labelIP.setText("IP")
|
||||
self.labelPort.setText("Port")
|
||||
elif self.qcombo.currentText() == "https":
|
||||
self.labelIP.setText("IP")
|
||||
self.labelPort.setText("Port")
|
||||
elif self.qcombo.currentText() == "tcp":
|
||||
self.labelIP.setText("IP")
|
||||
self.labelPort.setText("Port")
|
||||
elif self.qcombo.currentText() == "github":
|
||||
self.labelIP.setText("Project")
|
||||
self.labelPort.setText("Token")
|
||||
|
||||
|
||||
def checkAndSend(self):
|
||||
type = self.type.currentText()
|
||||
param1 = self.param1.text()
|
||||
param2 = self.param2.text()
|
||||
|
||||
result = [type, param1, param2]
|
||||
|
||||
self.procDone.emit(result)
|
||||
self.close()
|
||||
|
||||
+1
-1
Submodule core updated: 8493717ade...f951a4a73d
@@ -45,6 +45,8 @@ message Listener
|
||||
string type = 2;
|
||||
int32 port = 3;
|
||||
string ip = 4;
|
||||
string project = 6;
|
||||
string token = 7;
|
||||
int32 numberOfSession = 5;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ set(SOURCES_TEAMSERVER
|
||||
../core/listener/Listener.cpp
|
||||
../core/listener/ListenerTcp.cpp
|
||||
../core/listener/ListenerHttp.cpp
|
||||
../core/listener/ListenerGithub.cpp
|
||||
|
||||
../core/modules/ModuleCmd/ModuleCmd.cpp
|
||||
../../thirdParty/base64/base64.cpp
|
||||
|
||||
@@ -148,15 +148,14 @@ grpc::Status TeamServer::GetListeners(grpc::ServerContext* context, const teamse
|
||||
grpc::Status TeamServer::AddListener(grpc::ServerContext* context, const teamserverapi::Listener* listenerToCreate, teamserverapi::Response* response)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "AddListener";
|
||||
|
||||
int localPort = listenerToCreate->port();
|
||||
string localHost = listenerToCreate->ip();
|
||||
string type = listenerToCreate->type();
|
||||
|
||||
try
|
||||
{
|
||||
if (type == ListenerTcpType)
|
||||
{
|
||||
int localPort = listenerToCreate->port();
|
||||
string localHost = listenerToCreate->ip();
|
||||
std::unique_ptr<ListenerTcp> listenerTcp = make_unique<ListenerTcp>(localHost, localPort);
|
||||
m_listeners.push_back(std::move(listenerTcp));
|
||||
|
||||
@@ -164,6 +163,8 @@ grpc::Status TeamServer::AddListener(grpc::ServerContext* context, const teamser
|
||||
}
|
||||
else if (type == ListenerHttpType)
|
||||
{
|
||||
int localPort = listenerToCreate->port();
|
||||
string localHost = listenerToCreate->ip();
|
||||
std::unique_ptr<ListenerHttp> listenerHttp = make_unique<ListenerHttp>(localHost, localPort);
|
||||
m_listeners.push_back(std::move(listenerHttp));
|
||||
|
||||
@@ -171,11 +172,22 @@ grpc::Status TeamServer::AddListener(grpc::ServerContext* context, const teamser
|
||||
}
|
||||
else if (type == ListenerHttpsType)
|
||||
{
|
||||
int localPort = listenerToCreate->port();
|
||||
string localHost = listenerToCreate->ip();
|
||||
std::unique_ptr<ListenerHttp> listenerHttps = make_unique<ListenerHttp>(localHost, localPort, true);
|
||||
m_listeners.push_back(std::move(listenerHttps));
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "AddListener Https " << localHost << ":" << std::to_string(localPort);
|
||||
}
|
||||
else if (type == ListenerGithubType)
|
||||
{
|
||||
std::string token = listenerToCreate->token();
|
||||
std::string project = listenerToCreate->project();
|
||||
std::unique_ptr<ListenerGithub> listenerGithub = make_unique<ListenerGithub>(project, token);
|
||||
m_listeners.push_back(std::move(listenerGithub));
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "AddListener Github " << project << ":" << token;
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::exception &exc)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "listener/ListenerTcp.hpp"
|
||||
#include "listener/ListenerHttp.hpp"
|
||||
#include "listener/ListenerGithub.hpp"
|
||||
|
||||
#include "modules/AssemblyExec/AssemblyExec.hpp"
|
||||
#include "modules/Upload/Upload.hpp"
|
||||
|
||||
Reference in New Issue
Block a user