<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title />
	
	<link>http://www.megapanzer.com</link>
	<description />
	<lastBuildDate>Tue, 14 May 2013 20:45:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/megapanzer" /><feedburner:info uri="megapanzer" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>megapanzer</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>AyCarrumba 1.4 ready for download</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/wMeNjOxjv6M/</link>
		<comments>http://www.megapanzer.com/2013/05/14/aycarrumba-1-4-ready-for-download-2/#comments</comments>
		<pubDate>Tue, 14 May 2013 20:45:23 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[Tools & sources]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8621</guid>
		<description><![CDATA[Get the latest build of AyCarrumba (1.4) here. Please report the bugs you encounter.]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.megapanzer.com/wp-content/uploads/code-150x150.jpg" alt="code" width="75" height="75" class="alignright size-thumbnail wp-image-3203" />Get the latest build of AyCarrumba (1.4) <a href="http://www.megapanzer.com/wp-content/uploads/AyCarrumba_1_4.zip" title="AyCarrumba 1.4">here</a>. <br />Please report the bugs you encounter. </p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/wMeNjOxjv6M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2013/05/14/aycarrumba-1-4-ready-for-download-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2013/05/14/aycarrumba-1-4-ready-for-download-2/</feedburner:origLink></item>
		<item>
		<title>AyCarrumba 1.4 RC2</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/gBWT-2uVnYw/</link>
		<comments>http://www.megapanzer.com/2013/05/04/aycarrumba-1-4-rc2/#comments</comments>
		<pubDate>Sat, 04 May 2013 09:53:32 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[Tools & sources]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8603</guid>
		<description><![CDATA[This is the latest build of AyCarrumba release 1.4. To make it more stable, bugfree, solid and usable as many people as possible should download and use it on as many different environments as possible. I developed under Windows 7 with .Net 4. If you run Windows 7/8 with .Net 4.* on your computer, you [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.megapanzer.com/wp-content/uploads/code-150x150.jpg" alt="code" width="75" height="75" class="alignright size-thumbnail wp-image-3203" />This is the latest build of <strong>AyCarrumba release 1.4</strong>. To make it more stable, bugfree, solid and usable as many people as possible should download and use it on as many different environments as possible. I developed under Windows 7 with .Net 4.<br />
If you run <strong>Windows 7/8 with .Net 4.*</strong> on your computer, you have some minutes spare and want to contribute your share to this exciting project I invite you to download the RC2, install it, test it and report all bugs you encounter. You can do that either via Facebook messages, this <a href="http://www.megapanzer.com/contact/" title="Contact form">contact form</a> or via email (megapanzer@gmail.com). </p>
<p><strong>Thanks for your contribution!</strong></p>
<p>Download link : <a href="http://www.megapanzer.com/wp-content/uploads/AyCarrumba_1_4_RC2.zip">AyCarrumba_1_4_RC2</a></p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/gBWT-2uVnYw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2013/05/04/aycarrumba-1-4-rc2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2013/05/04/aycarrumba-1-4-rc2/</feedburner:origLink></item>
		<item>
		<title>AyCarrumba …</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/_rTVoJe1j5A/</link>
		<comments>http://www.megapanzer.com/2013/04/06/aycarrumba-2/#comments</comments>
		<pubDate>Sat, 06 Apr 2013 21:24:38 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[Info]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8588</guid>
		<description><![CDATA[All relevant features are implemented and it looks like it is becoming more and more stable. The plugins don&#8217;t interfere with each other anymore, two major bugs are fixed and on my system it is working smoothly. The plan for the coming weeks is &#8230; making the plugins more customizable so the users are not [...]]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.megapanzer.com/wp-content/uploads/code-150x150.jpg" alt="code" width="75" height="75" class="alignright size-thumbnail wp-image-3203" />All relevant features are implemented and it looks like it is becoming more and more stable. The plugins don&#8217;t interfere with each other anymore, two major bugs are fixed and on my system it is working smoothly.<br />
The plan for the coming weeks is &#8230;</p>
<ul>
<li><strong>making the plugins more customizable</strong> so the users are not depending on my configuration and settings.</li>
<li><strong>merging both DNS poisoning approaches</strong> in one module. Probably I integrate them in <a href="http://www.megapanzer.com/2012/04/11/ape-the-arp-poisoning-engine/" title="APE - ARP Poisoning Engine">APE</a>.</li>
<li>one really, really (!) necessary open task is<strong> assigning the whole program an architecture</strong>. The code at its current state is rather messy. To avoid chaos applying a clear structure inside the code and around whole the project is inevitable</li>
</ul>
<p>This will take some time. The weekend and evening are the only moments where I find enough time to work on it seriously. </p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/_rTVoJe1j5A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2013/04/06/aycarrumba-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2013/04/06/aycarrumba-2/</feedburner:origLink></item>
		<item>
		<title>Zeus Trojan Source Code</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/tUrRAn75V3g/</link>
		<comments>http://www.megapanzer.com/2013/02/22/zeus-trojan-source-code/#comments</comments>
		<pubDate>Fri, 22 Feb 2013 14:15:07 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[Bot sources]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[RAT sources]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[trojan]]></category>
		<category><![CDATA[ZeuS]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8410</guid>
		<description><![CDATA[&#160; &#160; &#160; Bot name Zeus Trojan &#160; Author - &#160; &#160; Written in C++ &#160; &#160; Description Zeus is a Trojan horse that steals banking information by Man-in-the-browser keystroke logging and Form Grabbing. It is spread mainly through drive-by downloads and phishing schemes. The various Zeus&#8217; botnets are estimated to include millions of compromised [...]]]></description>
				<content:encoded><![CDATA[<table border="0" width="100%">
<tbody>
<tr valign="top">
<td width="30%">&nbsp;</td>
<td width="50%">&nbsp;</td>
<td width="20%">&nbsp;</td>
</tr>
<tr valign="bottom">
<td><strong>Bot name</strong></td>
<td>Zeus Trojan</td>
<td rowspan="5">
<img src="http://www.megapanzer.com/wp-content/uploads/trojan_horse.jpeg" alt="trojanhorse" title="trojanhorse" width="100" height="96" class="alignright size-full wp-image-2132" />
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr valign="bottom">
<td><strong>Author</strong></td>
<td>-</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr valign="bottom">
<td><strong>Written in</strong></td>
<td>C++</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr valign="top">
<td><strong>Description</strong></td>
<td colspan="2">
Zeus is a Trojan horse that steals banking information by Man-in-the-browser keystroke logging and Form Grabbing. It is spread mainly through drive-by downloads and phishing schemes. The various Zeus&#8217; botnets are estimated to include millions of compromised computers.<br />
The Zeus Trojan-controlled machines are in 196 countries, including isolated states such as North Korea. The five countries with the most significant instances of infected machines are Egypt, the United States, Mexico, Saudi Arabia, and Turkey. Altogether, 2,411 companies and organizations are said to have been affected by the criminal operations running the botnet.</p>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr valign="top">
<td><strong>Downloads</strong></td>
<td colspan="2"><a href="http://www.megapanzer.com/wp-content/uploads/ZeuS-2.0.8.9.rar">Source</a> (Password : zeus)</td>
</tr>
</tbody>
</table>
<p><br/></p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/tUrRAn75V3g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2013/02/22/zeus-trojan-source-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2013/02/22/zeus-trojan-source-code/</feedburner:origLink></item>
		<item>
		<title>ARP Poisoning source code</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/eauCzbMEdAs/</link>
		<comments>http://www.megapanzer.com/2013/02/16/arp-poisoning-source-code/#comments</comments>
		<pubDate>Sat, 16 Feb 2013 21:15:00 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Tools & sources]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8397</guid>
		<description><![CDATA[I added new source codes to Github. Basic sniffer ARP Ping ARP Poison I packed everything into a Visual Studio (2010) Solutions. Download, open, compile and test it. Any feedback is welcome. More code will follow soon. Missing parts are the packet forwarder and a combination of poisoning and forwarding.]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.megapanzer.com/wp-content/uploads/code-150x150.jpg" alt="code" width="75" height="75" class="alignright size-thumbnail wp-image-3203" />I added new source codes to <a href="https://github.com/rubenunteregger/WinPcapExamples" title="WinPcap Examples " target="_blank">Github</a>.</p>
<ul>
<li>Basic sniffer</li>
<li>ARP Ping</li>
<li>ARP Poison</li>
</ul>
<p>I packed everything into a Visual Studio (2010) Solutions. Download, open, compile and test it. Any feedback is welcome.<br />
More code will follow soon. Missing parts are the packet forwarder and a combination of poisoning and forwarding.</p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/eauCzbMEdAs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2013/02/16/arp-poisoning-source-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2013/02/16/arp-poisoning-source-code/</feedburner:origLink></item>
		<item>
		<title>RunAsAdmin – Running program with administrator privileges</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/A2WMmugFiSc/</link>
		<comments>http://www.megapanzer.com/2013/01/06/runasadmin-running-program-with-administrator-privileges/#comments</comments>
		<pubDate>Sun, 06 Jan 2013 11:44:43 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Tools & sources]]></category>
		<category><![CDATA[Administrator]]></category>
		<category><![CDATA[Privileges]]></category>
		<category><![CDATA[UAC]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8369</guid>
		<description><![CDATA[Tool name : RunAsAdmin &#160; Description : RunAsAdmin is a tool to run a particular portion of the code under the elevated administrator privileges. If the user is an Administrator and has elevated privileges it will directly jump to the block where the elevated admin privileges are required. If the user is an administrator but [...]]]></description>
				<content:encoded><![CDATA[<table border="0" width="100%">
<tbody>
<tr valign="top">
<td width="30%"></td>
<td width="70%"></td>
</tr>
<tr valign="top">
<td><strong>Tool name</strong> :</td>
<td>RunAsAdmin</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr valign="top">
<td><strong>Description</strong> :</td>
<td>
RunAsAdmin is a tool to run a particular portion of the code under the elevated administrator privileges. If the user is an Administrator and has elevated privileges it will directly jump to the block where the elevated admin privileges are required. </p>
<p>If the user is an administrator but the privileges are not elevated yet RunAsAdmin will elevate them automatically and jump to the block where the elevated admin privileges are required. </p>
<p>If the user has no administrator privileges it calls the &#8220;RunAs&#8221; command and asks the user to run the program under elevated privileges. Depending on the UAC settings the user either has to type in a password, he has to confirm the process or there is no confirmation screen.
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr valign="top">
<td><strong>Tested on</strong> :</td>
<td>Windows 7</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td><strong>Feedback</strong> :</td>
<td>In case you encounter any problems with the tool, you have suggestions to improve it, or you tested it with a Windows version i&#8217;ve not yet tested please drop me an <a href="http://www.megapanzer.com/contact/">email</a>.</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr valign="top">
<td><strong>Downloads</strong> :</td>
<td>Version 0.1 – <a href="http://www.megapanzer.com/wp-content/uploads/RunAsAdmin.zip">Binary&#038;Source</a></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</tbody>
</table>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/A2WMmugFiSc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2013/01/06/runasadmin-running-program-with-administrator-privileges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2013/01/06/runasadmin-running-program-with-administrator-privileges/</feedburner:origLink></item>
		<item>
		<title>C – Encode Databuffer To Base64</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/GrxVAWZsnjU/</link>
		<comments>http://www.megapanzer.com/2012/12/30/c-encode-databuffer-to-base64/#comments</comments>
		<pubDate>Sun, 30 Dec 2012 12:10:11 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8305</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 BOOL ToBase64&#40;BYTE *pInput, int pInputLen, BYTE **pOutput, DWORD *pOutputLen&#41; &#123; BOOL lRetVal = FALSE; DWORD lBufSize = 0; &#160; if &#40;CryptBinaryToStringA&#40;pInput, pInputLen, CRYPT_STRING_BASE64, NULL, &#38;lBufSize&#41; &#38;&#38; lBufSize &#62; 0&#41; if &#40;&#40;*pOutput = &#40;BYTE *&#41; HeapAlloc&#40;GetProcessHeap&#40;&#41;, HEAP_ZERO_MEMORY, lBufSize+1&#41;&#41; != NULL&#41; if &#40;CryptBinaryToStringA&#40;pInput, [...]]]></description>
				<content:encoded><![CDATA[<p><br/><br />
<br/></p>
<div style="width: 690px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">BOOL ToBase64<span style="color: #009900;">&#40;</span>BYTE <span style="color: #339933;">*</span>pInput<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> pInputLen<span style="color: #339933;">,</span> BYTE <span style="color: #339933;">**</span>pOutput<span style="color: #339933;">,</span> DWORD <span style="color: #339933;">*</span>pOutputLen<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  BOOL lRetVal <span style="color: #339933;">=</span> FALSE<span style="color: #339933;">;</span>
  DWORD lBufSize <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>CryptBinaryToStringA<span style="color: #009900;">&#40;</span>pInput<span style="color: #339933;">,</span> pInputLen<span style="color: #339933;">,</span> CRYPT_STRING_BASE64<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lBufSize<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> lBufSize <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>pOutput <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BYTE <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> HeapAlloc<span style="color: #009900;">&#40;</span>GetProcessHeap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> HEAP_ZERO_MEMORY<span style="color: #339933;">,</span> lBufSize<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>CryptBinaryToStringA<span style="color: #009900;">&#40;</span>pInput<span style="color: #339933;">,</span> pInputLen<span style="color: #339933;">,</span> CRYPT_STRING_BASE64<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>LPSTR<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span>pOutput<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lBufSize<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        lRetVal <span style="color: #339933;">=</span> TRUE<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #339933;">*</span>pOutputLen <span style="color: #339933;">=</span> lBufSize<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span>lRetVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p><br/></p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/GrxVAWZsnjU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2012/12/30/c-encode-databuffer-to-base64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2012/12/30/c-encode-databuffer-to-base64/</feedburner:origLink></item>
		<item>
		<title>C – Sending HTTP POST request</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/_0DZ-tYfWC4/</link>
		<comments>http://www.megapanzer.com/2012/12/26/c-sending-http-post-request/#comments</comments>
		<pubDate>Wed, 26 Dec 2012 12:18:40 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8295</guid>
		<description><![CDATA[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 [...]]]></description>
				<content:encoded><![CDATA[<p><br/><br />
<br/></p>
<div style="width: 690px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">BOOL SendHTTPPost<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pHostname<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pURI<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pUserAgent<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pFileName<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  BOOL lRetVal <span style="color: #339933;">=</span> FALSE<span style="color: #339933;">;</span>
  HANDLE lInputFH <span style="color: #339933;">=</span> INVALID_HANDLE_VALUE<span style="color: #339933;">;</span>
  HINTERNET lInetInit <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
  HINTERNET lInetConn <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span> 
  HINTERNET lInetReq <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
  DWORD lBytesRead <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  DWORD lBytesWritten <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  DWORD lTotalBytesWritten <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> lTemp<span style="color: #009900;">&#91;</span>MAX_BUF_SIZE <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> lHeader<span style="color: #009900;">&#91;</span>MAX_BUF_SIZE <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  BYTE lBuffer<span style="color: #009900;">&#91;</span>MAX_BUF_SIZE<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  INTERNET_BUFFERS lBufferIn <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>pHostname <span style="color: #339933;">!=</span> NULL <span style="color: #339933;">&amp;&amp;</span> pURI <span style="color: #339933;">!=</span> NULL <span style="color: #339933;">&amp;&amp;</span> pFileName <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>PathFileExists<span style="color: #009900;">&#40;</span>pFileName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>      
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>lInputFH <span style="color: #339933;">=</span> CreateFile<span style="color: #009900;">&#40;</span>pFileName<span style="color: #339933;">,</span> GENERIC_READ<span style="color: #339933;">,</span> FILE_SHARE_READ<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> 
          OPEN_EXISTING<span style="color: #339933;">,</span> FILE_ATTRIBUTE_NORMAL<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> INVALID_HANDLE_VALUE<span style="color: #009900;">&#41;</span>
	  <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Set default User Agent.</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>pUserAgent <span style="color: #339933;">==</span> NULL<span style="color: #009900;">&#41;</span>
          pUserAgent <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.2.153.1 Safari/525.19&quot;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>lInetInit <span style="color: #339933;">=</span> InternetOpen <span style="color: #009900;">&#40;</span>pUserAgent<span style="color: #339933;">,</span> INTERNET_OPEN_TYPE_PRECONFIG<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span>
             <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>lInetConn <span style="color: #339933;">=</span> InternetConnect<span style="color: #009900;">&#40;</span>lInetInit<span style="color: #339933;">,</span> pHostname<span style="color: #339933;">,</span> INTERNET_DEFAULT_HTTP_PORT<span style="color: #339933;">,</span>
              NULL<span style="color: #339933;">,</span>NULL<span style="color: #339933;">,</span>INTERNET_SERVICE_HTTP<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
          <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>lInetReq <span style="color: #339933;">=</span> HttpOpenRequest<span style="color: #009900;">&#40;</span>lInetConn<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;POST&quot;</span><span style="color: #339933;">,</span> pURI<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                 <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
              lBufferIn.<span style="color: #202020;">dwStructSize</span> <span style="color: #339933;">=</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>INTERNET_BUFFERS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
              lBufferIn.<span style="color: #202020;">dwBufferTotal</span> <span style="color: #339933;">=</span> GetFileSize <span style="color: #009900;">&#40;</span>lInputFH<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
              <span style="color: #666666; font-style: italic;">// Add HTTP header</span>
              ZeroMemory<span style="color: #009900;">&#40;</span>lHeader<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>lHeader<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              <span style="color: #000066;">strcat</span><span style="color: #009900;">&#40;</span>lHeader<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Content-type: application/x-www-form-urlencoded&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              HttpAddRequestHeaders<span style="color: #009900;">&#40;</span>lInetReq<span style="color: #339933;">,</span> lHeader<span style="color: #339933;">,</span> strnlen<span style="color: #009900;">&#40;</span>lHeader<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>lHeader<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
                                    HTTP_ADDREQ_FLAG_REPLACE<span style="color: #339933;">|</span>HTTP_ADDREQ_FLAG_ADD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
              <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>HttpSendRequestEx<span style="color: #009900;">&#40;</span>lInetReq<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lBufferIn<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> HSR_INITIATE<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
              <span style="color: #009900;">&#123;</span>
                  <span style="color: #b1b100;">do</span> 
                  <span style="color: #009900;">&#123;</span> 
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ReadFile<span style="color: #009900;">&#40;</span>lInputFH<span style="color: #339933;">,</span> lBuffer<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>lBuffer<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lBytesRead<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#123;</span> 
                      <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;ReadFile failed on buffer %d.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> GetLastError<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
                      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> 
                    <span style="color: #009900;">&#125;</span> 
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>InternetWriteFile<span style="color: #009900;">&#40;</span>lInetReq<span style="color: #339933;">,</span> lBuffer<span style="color: #339933;">,</span> lBytesRead<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lBytesWritten<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#123;</span> 
                      <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;InternetWriteFile failed %d.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> GetLastError<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
                      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> 
                    <span style="color: #009900;">&#125;</span> 
&nbsp;
                    lTotalBytesWritten <span style="color: #339933;">+=</span> lBytesWritten<span style="color: #339933;">;</span> 
                  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>lBytesRead <span style="color: #339933;">==</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>lBuffer<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
                  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>lTotalBytesWritten <span style="color: #339933;">==</span> GetFileSize <span style="color: #009900;">&#40;</span>lInputFH<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    lRetVal <span style="color: #339933;">=</span> TRUE<span style="color: #339933;">;</span>
              <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if(HttpSendReque...</span>
              InternetCloseHandle<span style="color: #009900;">&#40;</span>lInetReq<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if ((lInetReq...</span>
            InternetCloseHandle<span style="color: #009900;">&#40;</span>lInetConn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if ((lInetCo...</span>
          InternetCloseHandle<span style="color: #009900;">&#40;</span>lInetInit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if ((lInetIn...</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if ((lInputFH = CreateFile(...</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if (PathFileExists(...</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if (pHostn...</span>
&nbsp;
  <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span>lRetVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p><br/></p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/_0DZ-tYfWC4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2012/12/26/c-sending-http-post-request/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2012/12/26/c-sending-http-post-request/</feedburner:origLink></item>
		<item>
		<title>C – Sending HTTP GET request</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/7JtODyri1Do/</link>
		<comments>http://www.megapanzer.com/2012/12/21/c-sending-http-get-request/#comments</comments>
		<pubDate>Fri, 21 Dec 2012 12:13:52 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8290</guid>
		<description><![CDATA[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 BOOL SendHTTPGet&#40;char *pHostname, char *pURI, char *pUserAgent&#41; [...]]]></description>
				<content:encoded><![CDATA[<p><br/><br />
<br/></p>
<div style="width: 690px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">BOOL SendHTTPGet<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pHostname<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pURI<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pUserAgent<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  BOOL lRetVal <span style="color: #339933;">=</span> FALSE<span style="color: #339933;">;</span>
  HINTERNET lInetInit <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
  HINTERNET lInetConn <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span> 
  HINTERNET lInetReq <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
  DWORD lBytesRead<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> lTemp<span style="color: #009900;">&#91;</span>MAX_BUF_SIZE <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>pHostname <span style="color: #339933;">!=</span> NULL <span style="color: #339933;">&amp;&amp;</span> pURI <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>pUserAgent <span style="color: #339933;">==</span> NULL<span style="color: #009900;">&#41;</span>
      pUserAgent <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.2.153.1 Safari/525.19&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>lInetInit <span style="color: #339933;">=</span> InternetOpen <span style="color: #009900;">&#40;</span>pUserAgent<span style="color: #339933;">,</span> INTERNET_OPEN_TYPE_PRECONFIG<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>lInetConn <span style="color: #339933;">=</span> InternetConnect<span style="color: #009900;">&#40;</span>lInetInit<span style="color: #339933;">,</span> pHostname<span style="color: #339933;">,</span> INTERNET_DEFAULT_HTTP_PORT<span style="color: #339933;">,</span> 
          NULL<span style="color: #339933;">,</span>NULL<span style="color: #339933;">,</span>INTERNET_SERVICE_HTTP<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>lInetReq <span style="color: #339933;">=</span> HttpOpenRequest<span style="color: #009900;">&#40;</span>lInetConn<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;GET&quot;</span><span style="color: #339933;">,</span> pURI<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
           <span style="color: #339933;">!=</span> NULL<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>HttpSendRequest<span style="color: #009900;">&#40;</span>lInetReq<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
          <span style="color: #009900;">&#123;</span>
            lRetVal <span style="color: #339933;">=</span> TRUE<span style="color: #339933;">;</span>
            ZeroMemory<span style="color: #009900;">&#40;</span>lTemp<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>lTemp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>InternetReadFile<span style="color: #009900;">&#40;</span>lInetReq<span style="color: #339933;">,</span> lTemp<span style="color: #339933;">,</span> MAX_BUF_SIZE<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lBytesRead<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
              <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;&gt; %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> lTemp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
              ZeroMemory<span style="color: #009900;">&#40;</span>lTemp<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>lTemp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
              <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>lBytesRead <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// while (InternetRead...</span>
          <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if(HttpSendReque...</span>
          InternetCloseHandle<span style="color: #009900;">&#40;</span>lInetReq<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if ((lInetReq...</span>
        InternetCloseHandle<span style="color: #009900;">&#40;</span>lInetConn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if ((lInetCo...</span>
      InternetCloseHandle<span style="color: #009900;">&#40;</span>lInetInit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if ((lInetIn..</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if (pHostn...</span>
&nbsp;
  <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span>lRetVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p><br/></p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/7JtODyri1Do" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2012/12/21/c-sending-http-get-request/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2012/12/21/c-sending-http-get-request/</feedburner:origLink></item>
		<item>
		<title>C – Decrypt Data With AES</title>
		<link>http://feedproxy.google.com/~r/megapanzer/~3/ycHRsmZUsFg/</link>
		<comments>http://www.megapanzer.com/2012/12/16/c-decrypt-data-with-aes/#comments</comments>
		<pubDate>Sun, 16 Dec 2012 12:41:26 +0000</pubDate>
		<dc:creator>carrumba</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[AES]]></category>
		<category><![CDATA[Wincrypt]]></category>

		<guid isPermaLink="false">http://www.megapanzer.com/?p=8285</guid>
		<description><![CDATA[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 BOOL AESDecrypt&#40;char *pPassword, char *pData, DWORD pDataLen, DWORD *pOutputDataLen&#41; &#123; BOOL lRetVal = FALSE; HCRYPTPROV lCryptProvHandle = 0; HCRYPTKEY lKeyHandle [...]]]></description>
				<content:encoded><![CDATA[<p><br/><br />
<br/></p>
<div style="width: 690px;">

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">BOOL AESDecrypt<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pPassword<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>pData<span style="color: #339933;">,</span> DWORD pDataLen<span style="color: #339933;">,</span> DWORD <span style="color: #339933;">*</span>pOutputDataLen<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  BOOL lRetVal <span style="color: #339933;">=</span> FALSE<span style="color: #339933;">;</span>
  HCRYPTPROV lCryptProvHandle <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  HCRYPTKEY lKeyHandle <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  HCRYPTHASH lHashHandle <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>CryptAcquireContext<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>lCryptProvHandle<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> PROV_RSA_AES<span style="color: #339933;">,</span> 
      CRYPT_VERIFYCONTEXT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>CryptCreateHash<span style="color: #009900;">&#40;</span>lCryptProvHandle<span style="color: #339933;">,</span> CALG_SHA_256<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lHashHandle<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>CryptHashData<span style="color: #009900;">&#40;</span>lHashHandle<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>PBYTE<span style="color: #009900;">&#41;</span> pPassword<span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span>DWORD<span style="color: #009900;">&#41;</span> <span style="color: #000066;">strlen</span><span style="color: #009900;">&#40;</span>pPassword<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>CryptDeriveKey<span style="color: #009900;">&#40;</span>lCryptProvHandle<span style="color: #339933;">,</span> CALG_AES_256<span style="color: #339933;">,</span> lHashHandle<span style="color: #339933;">,</span> 
            CRYPT_EXPORTABLE<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>lKeyHandle<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>	
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>CryptDecrypt<span style="color: #009900;">&#40;</span>lKeyHandle<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> TRUE<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>BYTE <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> pData<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>pDataLen<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
          <span style="color: #009900;">&#123;</span>
            <span style="color: #339933;">*</span>pOutputDataLen <span style="color: #339933;">=</span> pDataLen<span style="color: #339933;">;</span>
            lRetVal <span style="color: #339933;">=</span> TRUE<span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #b1b100;">else</span>
            <span style="color: #339933;">*</span>pOutputDataLen <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
          CryptDestroyKey<span style="color: #009900;">&#40;</span>lKeyHandle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if (CryptDeriveKey(...</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if (CryptHashData(...</span>
      CryptDestroyHash<span style="color: #009900;">&#40;</span>lHashHandle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if (CryptCreateHash(...</span>
    CryptReleaseContext<span style="color: #009900;">&#40;</span>lCryptProvHandle<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// if (CryptAcquireContext(...</span>
&nbsp;
  <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span>lRetVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</div>
<p><br/></p>
<img src="http://feeds.feedburner.com/~r/megapanzer/~4/ycHRsmZUsFg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.megapanzer.com/2012/12/16/c-decrypt-data-with-aes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.megapanzer.com/2012/12/16/c-decrypt-data-with-aes/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.986 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-05-25 17:57:56 -->
