This repository has been archived by the owner on May 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathcreate-listener.php
177 lines (176 loc) · 8.38 KB
/
create-listener.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
// include files
require_once("includes/check-authorize.php");
require_once("includes/functions.php");
$empire_listener_options = "";
if (isset($_GET['type']))
{
if (strlen($_GET['type'])>0)
{
$listener_type = $_GET['type'];
$arr_result = get_current_listener_options($sess_ip, $sess_port, $sess_token, $listener_type);
if(array_key_exists("listeneroptions", $arr_result))
{
$empire_listener_options .= '<table class="table table-hover table-striped"><thead><tr><th>Name</th>';
foreach($arr_result["listeneroptions"] as $key => $value)
{
foreach($value as $key1 => $value1)
{
$key1 = ucfirst(htmlentities($key1));
$empire_listener_options .= "<th>$key1</th>";
}
break;
}
$empire_listener_options .= '</thead><tbody>';
foreach($arr_result["listeneroptions"] as $key => $value)
{
$key = htmlentities($key);
if($key != "Name")
{
$empire_listener_options .= "<tr><td>$key</td>";
}
foreach($value as $key1 => $value1)
{
if($key != "Name")
{
$value1 = htmlentities($value1);
if($key1 == "Value")
{
$empire_listener_options .= "<td><div class='form-group'><input type='text' class='form-control' id='$key' name='$key' value='$value1'></div></td>";
}
elseif($key1 == "Required")
{
if($value1 == True)
{
$empire_listener_options .= "<td>Yes</td>";
}
else
{
$empire_listener_options .= "<td>No</td>";
}
}
else
{
$empire_listener_options .= "<td>".$value1."</td>";
}
}
}
$empire_listener_options .= "</tr>";
}
$empire_listener_options .= '</tbody></table>';
}
else
{
$empire_listener_options = "<div class='alert alert-danger'>Unexpected response</div>";
}
}
}
$empire_create_listener = "";
if(isset($_POST) && !empty($_POST))
{
$arr_data = array();
$listener_type = $_POST['listener_type'];
//Remove listener_type from POST so that it is not part of the arr_data else it would cause HTTP 400 error in the API
if(isset($_POST["listener_type"]))
{
unset($_POST["listener_type"]);
}
//Remove "CertPath" item from $_POST if it is not set
//If it exists and listener is of HTTP then it is converted into HTTPS without any error
if(isset($_POST["CertPath"]) && strlen($_POST["CertPath"])<=0)
{
unset($_POST["CertPath"]);
}
foreach($_POST as $key => $value)
{
$arr_data[$key] = html_entity_decode(urldecode($value));
}
$arr_result = create_listener($sess_ip, $sess_port, $sess_token, $listener_type, $arr_data);
if(array_key_exists("success", $arr_result))
{
if($arr_result["success"] == True)
{
if(array_key_exists("msg", $arr_result))
{
$empire_create_listener = "<div class='alert alert-success'><span class='glyphicon glyphicon-ok'></span> ".ucfirst(htmlentities($arr_result["msg"]))."</div>";
}
else
{
$empire_create_listener = "<div class='alert alert-success'><span class='glyphicon glyphicon-ok'></span> ".ucfirst(htmlentities($arr_result["success"]))."</div>";
}
}
else
{
if(array_key_exists("msg", $arr_result))
{
$empire_create_listener = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> ".ucfirst(htmlentities($arr_result["msg"]))."</div>";
}
else
{
$empire_create_listener = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> Listener creation failed.</div>";
}
}
}
elseif(array_key_exists("error", $arr_result))
{
$empire_create_listener = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> ".ucfirst(htmlentities($arr_result["error"]))."</div>";
}
else
{
$empire_create_listener = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> Unexpected response.</div>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Empire: Create Listener</title>
<?php @require_once("includes/head-section.php"); ?>
</head>
<body>
<div class="container">
<?php @require_once("includes/navbar.php"); ?>
<br>
<div class="panel-group">
<div class="panel panel-primary" style="overflow: visible">
<div class="panel-heading">Create Listener</div>
<div class="panel-body">
<form role="form" method="post" action="create-listener.php" class="form-inline">
<div class="form-group">
<div class="dropdown">
<?php $listener_type_html = "Listener Type"; if (isset($_GET['type'])) { if (strlen($_GET['type'])>0) { $listener_type_html = htmlentities($_GET['type']); } } ?>
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="listener_type" name="listener_type" value="<?php echo $listener_type_html; ?>"> <?php echo $listener_type_html; ?> <span class="caret"></span></button>
<input type="hidden" name="listener_type" value="<?php echo $listener_type_html; ?>">
<ul class="dropdown-menu">
<li><a href="#" onclick='location.href="create-listener.php?type=http"'>http</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=http_hop"'>http_hop</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=http_mapi"'>http_mapi</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=http_foreign"'>http_foreign</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=http_com"'>http_com</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=onedrive"'>onedrive</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=dbx"'>dbx</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=meterpreter"'>merterpreter</a></li>
<li><a href="#" onclick='location.href="create-listener.php?type=redirector"'>redirector</a></li>
</ul>
</div>
</div>
<div class="form-group">
<input type="text" class="form-control" id="listener-name" placeholder="Listener Name" name="Name" required>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">Create</button>
</div>
<?php if (strlen($empire_create_listener)>0) { echo '<div class="form-group"><br>'.$empire_create_listener.'</div>'; } ?>
<br><br>
<b>Additional Options:</b>
<br><br>
<?php if (strlen($empire_listener_options)>0) { echo $empire_listener_options; } else { echo '<div class="alert alert-danger">You have not selected any "Listener Type" above. Select one to view options for it.</div>'; } ?>
</form>
</div>
</div>
</div>
<br>
</div>
<?php @require_once("includes/footer.php"); ?>
</body>
</html>