Getting the IE Address URL directly!
As of right now, I am trying to fetch the URL that exists in the Internet Explorer address bar. I tried using registry to call out to "Software\Microsoft\Internet Explorer\TypedURLs\url1" but Internet Explorer only changes the registry if the adress bar's URL windowas entered by the user! If you were to link to another page with a click, the registry would not be updated. What I am doing right now is to use a different method, to find the window of the address bar and retrieve the text directly. However, I find this method rather hard although proven effecient, a little of Google search got me into this link which right now I am using. Whether or not it gives me the final solution, I will post it up later in a full article on how to retrieve it with the source code available! This link has also provided me a good tool to check on windows classes, texts and its child, a little much more better than the Microsoft Spy++. The tool is called Windowse. Below is the link to the article that is helping me right now.
Article: http://delphi.about.com/od/windowsshellapi/l/aa060303a.htm
R
For those that are interested in contacting the windows registry via C, here's a list of WinAPI functions that you need to know.
RegOpenKeyEx
RegCreateKeyEx
RegSetValueEx
RegQueryValueEx
RegCloseKey
Complete list of registry functions - MSDN
If you need a tutorial on step by step for each functions, read LeetCoders - Registry Operations using Win32
Now here's a shortcut function which is usually developed for retrieving (stealing) serials for games and applications. It is called GetKeyData(HKEY, char *, char *, LPBYTE, DWORD). To use it simply place the code below. storeHere would be a variable to store the retrieved value of the key.
GetKeyData(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "ApplicationName", storeHere, strlen(storeHere));
[code]
int GetKeyData(HKEY hRootKey, char *subKey, char *value, LPBYTE data, DWORD cbData)
{
HKEY hKey;
if(RegOpenKeyEx(hRootKey, subKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
return 0;
if(RegQueryValueEx(hKey, value, NULL, NULL, data, &cbData) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return 0;
}
RegCloseKey(hKey);
return 1;
}
[/code]
Since there is the GetKeyData, there should also be the SetKeyData(HKEY, char *, DWORD, char *, LPBYTE, DWORD). An example to use would be
SetKeyData(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", REG_SZ, "ApplicationName", "C:\ApplicationPath\ApplicationName.exe", strlen("C:\ApplicationPath\ApplicationName.exe"));
[code]
int SetKeyData(HKEY hRootKey, char *subKey, DWORD dwType, char *value, LPBYTE data, DWORD cbData)
{
HKEY hKey;
if(RegCreateKey(hRootKey, subKey, &hKey) != ERROR_SUCCESS)
return 0;
if(RegSetValueEx(hKey, value, 0, dwType, data, cbData) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return 0;
}
RegCloseKey(hKey);
return 1;
}
[/code]
Recursive File Search in C | Source Code
This source code below is written by se7en from LeetCoders. It is capable of running through the enter C drive in 8 seconds on my computer finding more than 230,000 files. Although the downside of it is that it costs quite an amount of CPU usage during its process. You might try to optimize it by placing Sleep function or something that is possible in reducing the CPU usage.
HTTP File Downloader for Linux and Windows in C | Source Code
A member in HackForums by the handle Jakash3 has posted a source code on how to download files from the Internet that can be compiled in both Linux and Windows. Another great feature is that it supports IPv6.
The official way of writing a crypter in C | Source Code
mindlessdeath, a member from HackForums have posted a thread regarding how to write a crypter in C! I find this source code a very good example for people that are trying to learn to write their own crypter. Compared to any other source codes that are posted on the internet, the author of this source code gave a very detailed information on each line on what the statements does. In order to use this source code without much trouble, there are some prerequisites that was mentioned by the author himself.
Decrypt Firefox 3.5 and 3.6 stored passwords in C | Source Code | Application
If you have already decrypted passwords for Firefox 1, 2 and 3 (if you need them, it's here), here is the source code in C that helps you decrypt Firefox passwords for version 3.5 and 3.6! This source code is written by ZeR0 from HackHound.org. This source code is generally open source by the author but the terms of use is to give credits if you use it.
Download source code here.
Download binary / application here.
Listing processes for all users in C
While i was searching online for a way to display processes for all users, i came across this source code which was coded profesionally. The source code can be found here. Be sure to check their homepage here too for more source codes.
Win32 samples
Today i came across a very interesting website while searching for a method to display processes for all users! This website, http://win32.mvps.org/ provides alot of useful information coded in C! As a C/C++ programmer, it is highly suggested to give this website a visit! As for the source code i was looking for (displaying processes for all users), it is here!
Visit it for a better you here.
Placing an image file in an executable in C
If you ever wanted to place an image file into the executable or store any resources in it, this post will be able to help you. If you have previously read Builder & Stub | How to create your own builder and stub in C (using Resource), you will be able to understand this post easily. We are using the similar method by placing the image in the resource data. In this post, i am creating an application that extracts the image that has been placed in the resource data and place it in a file and execute the file.
Array of pointers in C
Did you ever have a need to store strings in a string arrays and not waste spaces? In this post i will be explaining some of the ways that you can save yourself from destroying the RAM!
Microsoft Visual Studio 2010 Express
Unleash your Creativity!
The Visual Studio® 2010 Express is a set of free tools which offers you an exciting experience with the new integrated development environment, a new editor built in Windows® Presentation Foundation (WPF) and support for the new .NET Framework 4.
Powerful Set of Free Tools
Choose the language that's right for you.
- Microsoft® Visual Basic® 2010 Express is ideal for the developer learning to program on Microsoft® Windows®.
- Microsoft® Visual C#® 2010 Express offers a great combination of power and productivity for Windows developers building on .NET.
- Microsoft® Visual C++® 2010 Express provides developers the horsepower with a finer degree of control than the other Visual Studio Express productions.
Features
- Visual Studio® 2010 Express supports the new .NET Framework 4.
- Visual Studio® 2010 Express products have a new integrated development environment (IDE) including a new Windows Presentation Framework code editor.
- In this new release, Visual Studio® 2010 Express gains multi-monitor support as well as part of the new IDE.
- Unique to Visual Studio® 2010 Express is a new streamlined user experience that focuses on the most common commands by hiding some of the more advanced menus and toolbars. These are easily accessible by users via the Tools / Settings menu.
- Visual Studio® 2010 Express offers a new Start Page.
Source: http://www.microsoft.com/express/Windows/
TCP / IP Sockets in C | eBook
Are you interested in building your own TCP / IP application in C? Learn how to make client server applications such as Instant Messaging or apply TCP / IP onto your existing system for further benefit. By mastering the skills of using sockets in C, you can develop applications that uses the FTP as well as SMTP protocol. To send email or to connect to your own FTP server as well as searching through Google. The possibility for using sockets are unlimited! TCP / IP Sockets in C Practical Guide For Programmers written by Michael J. Donahoo and Kenneth L. Calvert is a good book to start with. By assuming that you have the basics of C programming, it helps you to master the Winsock functions. At the end of the day, you will be able to create multi-threaded server that accepts multiple connections at a time. Apart from that it also gives a brief example of source code for writing a client server using the UDP protocol.
Be reminded that it is TCP / IP for C which means that it is fully focused on C. However there is a small chapter at the end which gives a guidance in C++. This book is the best book you can get to jump start your programming skills in handling sockets in C! Even if you have already learnt sockets, it is a good idea to check the source codes that are taught as their way of coding gives a proper idea on how you should write them well.
Click here to download.
DLL Injection | What it is
In computer programming, DLL injection is a technique used to run code within the address space of another process by forcing it to load a dynamic-link library.[1] DLL injection is often used by third-party developers to influence the behavior of a program in a way its authors did not anticipate or intend.[1][2][3] For example, the injected code could trap system function calls,[4][5] or read the contents of password textboxes, which cannot be done the usual way.[6]
Approaches on Microsoft Windows
There are at least four ways to force a program to load a DLL on Microsoft Windows:
- DLLs listed under the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLswill be loaded into every process that links to User32.dll as that DLL attaches itself to the process.[5][7][8][9] - Process manipulation functions such as CreateRemoteThread can be used to inject a DLL into a program after it has started.[5][6][10][11][12][13]
- Get a handle to the target process. This can be done by spawning the process[14][15] or by keying off something created by that process that is known to exist – for instance, a window with a predictable title,[16] or by obtaining a list of running processes[17] and scanning for the target executable's filename.[18]
- Allocate some memory in the target process,[19] and the name of the DLL to be injected is written to it.[10][20]
- This step can be skipped if a suitable DLL name is already available in the target process. For example, if a process links to ‘User32.dll’, ‘GDI32.dll’, ‘Kernel32.dll’ or any other library whose name ends in ‘32.dll’, it would be possible to load a library named ‘32.dll’. This technique has in the past been demonstrated to be effective against a method of guarding processes against DLL injection.[21]
- Create a new thread in the target process[22] with the thread's start address set to be the address of LoadLibrary and the argument set to the address of the string just uploaded into the target.[10][23]
- Instead of writing the name of a DLL-to-load to the target and starting the new thread at LoadLibrary, one can write the code-to-be-executed to the target and start the thread at that code.[6]
- The operating system will now call DllMain in the injected DLL.[10][24]
- Note that without precautions, this approach can be detected by the target process due to the DLL_THREAD_ATTACH notifications sent to every loaded module as a thread starts.[24]
- Windows hooking calls such as SetWindowsHookEx.[2][5][6][25][26][27]
- Use the debugging functions to pause all threads, and then hijack an existing thread in the application to execute injected code, that in turn could load a DLL.[4][28][29]
In Windows Vista, Microsoft introduced the notion of a protected process. Such processes are immune from DLL Injection.[30]
Source: Wikipedia
Approaches on Microsoft Windows
There are at least four ways to force a program to load a DLL on Microsoft Windows:
- DLLs listed under the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLswill be loaded into every process that links to User32.dll as that DLL attaches itself to the process.[5][7][8][9] - Process manipulation functions such as CreateRemoteThread can be used to inject a DLL into a program after it has started.[5][6][10][11][12][13]
- Get a handle to the target process. This can be done by spawning the process[14][15] or by keying off something created by that process that is known to exist – for instance, a window with a predictable title,[16] or by obtaining a list of running processes[17] and scanning for the target executable's filename.[18]
- Allocate some memory in the target process,[19] and the name of the DLL to be injected is written to it.[10][20]
- This step can be skipped if a suitable DLL name is already available in the target process. For example, if a process links to ‘User32.dll’, ‘GDI32.dll’, ‘Kernel32.dll’ or any other library whose name ends in ‘32.dll’, it would be possible to load a library named ‘32.dll’. This technique has in the past been demonstrated to be effective against a method of guarding processes against DLL injection.[21]
- Create a new thread in the target process[22] with the thread's start address set to be the address of LoadLibrary and the argument set to the address of the string just uploaded into the target.[10][23]
- Instead of writing the name of a DLL-to-load to the target and starting the new thread at LoadLibrary, one can write the code-to-be-executed to the target and start the thread at that code.[6]
- The operating system will now call DllMain in the injected DLL.[10][24]
- Note that without precautions, this approach can be detected by the target process due to the DLL_THREAD_ATTACH notifications sent to every loaded module as a thread starts.[24]
- Windows hooking calls such as SetWindowsHookEx.[2][5][6][25][26][27]
- Use the debugging functions to pause all threads, and then hijack an existing thread in the application to execute injected code, that in turn could load a DLL.[4][28][29]
In Windows Vista, Microsoft introduced the notion of a protected process. Such processes are immune from DLL Injection.[30]
MSN Messenger Protocol
Have you ever wanted to create your own program that communicates with the MSN instant messaging tool? This is possible by learning how MSN works in the eyes of a programmer! Take a look at http://www.hypothetic.org.
Simple phonebook application in C
There was a small phonebook code challenge to build the shortest at LeetCoders. Here's a little of what i did for fun. Functions include add contact, remove contact, search contact and display contacts.
[code]
#include <stdio.h>
#define PHONEBOOK_SIZE 512
#define FLUSH fflush(stdin); // fpurge(stdin) for linux
typedef struct
{
char name[32 + 1];
char mobile[32 + 1];
}PHONEBOOK, *PPHONEBOOK;
void AddContact(PHONEBOOK *);
void RemoveContact(PHONEBOOK *);
void SearchContact(PHONEBOOK *);
void DisplayContact(PHONEBOOK *);
short selection;
short size;
int main(int argc, char **argv)
{
PHONEBOOK pb[PHONEBOOK_SIZE];
selection = 0;
size = 0;
for( ; ; )
{
printf("1 - Add contact\n"
"2 - Remove contact\n"
"3 - Search contact\n"
"4 - Display all contacts\n"
"0 - Exit\n\n"
"Select an option: ");
FLUSH;
scanf("%d", &selection);
switch(selection)
{
case 1:
AddContact(&pb);
break;
case 2:
RemoveContact(&pb);
break;
case 3:
SearchContact(&pb);
break;
case 4:
DisplayContact(&pb);
break;
case 0:
printf("Thanks for using...\n");
return 0;
default:
printf("Invalid option selected...\n");
break;
}
printf("\n");
}
return 0;
}
void AddContact(PHONEBOOK *pb)
{
for( ; ; )
{
printf("Enter name: ");
FLUSH;
scanf("%32[^\n]", pb[size].name);
printf("Enter mobile number: ");
FLUSH;
scanf("%32[^\n]", pb[size].mobile);
printf("Confirm (Y - yes | N - no | B - back): ");
FLUSH;
scanf("%c", &selection);
switch(selection)
{
case 'y':
case 'Y':
size++;
printf("Added contact...\n");
return;
case 'n':
case 'N':
memset(pb[size].name, 0, 32 + 1);
memset(pb[size].mobile, 0, 32 + 1);
break;
case 'b':
case 'B':
memset(pb[size].name, 0, 32 + 1);
memset(pb[size].mobile, 0, 32 + 1);
printf("No contact added...\n");
return;
default:
printf("Invalid option selected... default to N\n");
break;
}
printf("\n");
}
}
void RemoveContact(PHONEBOOK *pb)
{
char name[32 + 1];
int i, j;
for( ; ; )
{
printf("Enter name (BK - back): ");
FLUSH;
scanf("%32[^\n]", name);
if((name[0] == 'b' || name[0] == 'B') && (name[1] == 'k' || name[1] == 'K') && name[2] == '\0')
return;
for(i = 0 ; i < size ; i++)
{
if(strstr(strlwr(pb[i].name), strlwr(name)) != 0)
{
printf("ID : %d\n", i+1);
printf("Name : %s\n", pb[i].name);
printf("Mobile: %s\n", pb[i].mobile);
printf("\n");
printf("Remove contact (Y - yes | N - no | B - back):");
FLUSH;
scanf("%c", &selection);
switch(selection)
{
case 'y':
case 'Y':
printf("Removing contact: %s\n", pb[i].name);
for(j = i ; j < size ; j++)
{
strcpy(pb[j].name, pb[j+1].name);
strcpy(pb[j].mobile, pb[j+1].mobile);
}
memset(pb[size].name, 0, 32 + 1);
memset(pb[size].mobile, 0, 32 + 1);
size--;
i--;
printf("Contact removed...\n");
break;
case 'n':
case 'N':
break;
case 'b':
case 'B':
return;
default:
printf("Invalid option selected... default to N\n");
break;
}
}
}
printf("\n");
}
printf("\n");
}
void SearchContact(PHONEBOOK *pb)
{
char name[32 + 1];
int i;
for( ; ; )
{
printf("Enter name (BK - back): ");
FLUSH;
scanf("%32[^\n]", name);
if((name[0] == 'b' || name[0] == 'B') && (name[1] == 'k' || name[1] == 'K') && name[2] == '\0')
return;
for(i = 0 ; i < size ; i++)
{
if(strstr(strlwr(pb[i].name), strlwr(name)) != 0)
{
printf("ID : %d\n", i+1);
printf("Name : %s\n", pb[i].name);
printf("Mobile: %s\n", pb[i].mobile);
printf("\n");
}
}
printf("\n");
}
}
void DisplayContact(PHONEBOOK *pb)
{
int i;
for(i = 0 ; i < size ; i++)
{
printf("ID : %d\n", i+1);
printf("Name : %s\n", pb[i].name);
printf("Mobile: %s\n", pb[i].mobile);
printf("\n");
}
}
[/code]
MuteX | How to create a single instance application in C
[code]
#include <windows.h>
#include <stdio.h>
#define MUTEX_NAME "mutex name here, anyname"
int main()
{
HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, MUTEX_NAME);
if(hMutex == NULL)
{
// no duplicate instances found
hMutex = CreateMutex(NULL, FALSE, MUTEX_NAME);
}
else
{
// a duplicate was found
return 0;
}
printf("Created console\n");
getchar();
return 1;
}
[/code]
As you can see, there's OpenMuteX and CreateMuteX function that has been used. To briefly explain this, OpenMuteX opens a handle to check whether a mutex has been created. If it returns the value NULL, it means that no mutex of the current string has been created. So when it is NULL, CreateMuteX is called to create the mutex with the string MUTEX_NAME that has been defined. Leave a feedback if you feel that there's lack of information.
Black Hole | Create pixel on the desktop and expand
[code]
#include <windows.h>
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
HDC hDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
POINT pCurPos;
RECT rRect;
HBRUSH hBrush = (HBRUSH)(CreateSolidBrush(RGB(0, 0, 0)));
int iConst = 1;
for( ; ; Sleep(1000))
{
if (GetAsyncKeyState(VK_ESCAPE) != 0)
break;
iConst += 3;
GetCursorPos(&pCurPos);
rRect.left = pCurPos.x - iConst;
rRect.top = pCurPos.y - iConst;
rRect.right = pCurPos.x + iConst;
rRect.bottom = pCurPos.y + iConst;
FillRect(hDC, &rRect, hBrush);
}
DeleteDC(hDC);
return EXIT_SUCCESS;
}
[/code]
I'm not sure where i got this a year ago but generally this code create a black pixel on your desktop. It will terminate only if you press ESCAPE which is detected by GetAsyncKeyState.
Have you ever cracked Caesar Cipher
Last week... or two, my class lecturer asked us to decipher a caesar manually. Since i had my laptop with me i just made a quick Caesar decipher application in 5 minutes to show it to her, the lecturer the answer.
Sucks... totally! I wish there was something more to it...
GDWS | GenesisDatabase WLM Stealer
GDWS is an application that i have created using C without relying on resources for its GUI. It's simple to use and requires no driver reliability however it only works on Windows only.
Functions
- GUI in C
- retrieve stored WLM passwords
- run website in a hidden window via IE or FF (using socket)
- intermediate socket usage
- socket to load website
Download
Download Binary
Download Source Code
Note: If anyone requests for the source code, it would be generous of you to direct them here. I know it will consume your time but i'm sure a good deed is always worth it - what comes around goes around.
Creating application with a single instance in C and VB .NET
Most of us prefer to have single instances application to make it look professional or probably some other personal reason especially making malicious applications too. Here is the source code for the 2 languages that has been mentioned.
C
[code]
#include <windows.h>
int main()
{
char *mutex = "some name here";
HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, mutex);
if(hMutex == NULL)
{
hMutex = CreateMutex(NULL, FALSE, mutex);
}
else
{
MessageBox(0, "Instance Exists!", 0, 0);
return 0;
}
return 0;
}
[/code]
VB .NET
[code]
Function PrevInstance() As Boolean
If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
Return True
Else
Return False
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If PrevInstance() = True Then
MsgBox("Instance Exists!")
End
End If
End Sub
[/code]