新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 程序運行之后如何實現(xiàn)把自己刪除

        程序運行之后如何實現(xiàn)把自己刪除

        作者: 時間:2012-06-26 來源:網(wǎng)絡(luò) 收藏

        近日看到網(wǎng)友詢問的方法,不知大家對木馬甚么的興趣實在太濃,還是想要這樣的效果:用戶只要一,可執(zhí)行文件就沒有了,可是還是在跑,膽小的只怕要喊鬼呀!,老婆,快出來看上帝甚么的

        本文引用地址:http://www.104case.com/article/148855.htm

          。其實最典型的用法是寫反安裝程序. 閑來無事,Bear掰到一種還算巧妙的“”的方法。

          大家都知道,一般的程序的時候,可執(zhí)行文件本身是被操作系統(tǒng)保護的,不能用改寫的方式訪問,更別提在本身還在運行的時侯了。在Lu0的主頁上看到一種UNDOCUMENT的方法,通過改變系統(tǒng)底層的文件訪問模式刪除自己,那是實在功夫。我看了很是佩服。但是有沒有一種用在MSDN上就能查到的函數(shù)呢?有!Jeffrey Richter給我們做了一個范例:

          DeleteMe.CPP

          Module name: DeleteMe.cpp

          Written by: Jeffrey Richter

          Description: Allows an EXEcutable file to delete itself

          **************************************************/

          #include

          #include

          #include

          /////////////////////////////////////////////////

          int WINAPI WinMain(HINSTANCE h, HINSTANCE b, LPSTR psz, int n) {

          // Is this the Original EXE or the clone EXE?

          // If the command-line 1 argument, this is the Original EXE

          // If the command-line >1 argument, this is the clone EXE

          if (__argc == 1) {

          // Original EXE: Spawn clone EXE to delete this EXE

          // Copy this EXEcutable image into the user's temp directory

          TCHAR szPathOrig[_MAX_PATH], szPathClone[_MAX_PATH];

          GetModuleFileName(NULL, szPathOrig, _MAX_PATH);

          GetTempPath(_MAX_PATH, szPathClone);

          GetTempFileName(szPathClone, __TEXT(Del), 0, szPathClone);

          CopyFile(szPathOrig, szPathClone, FALSE);

          //***注意了***:

          // Open the clone EXE using FILE_FLAG_DELETE_ON_CLOSE

          HANDLE hfile = CreateFile(szPathClone, 0, FILE_SHARE_READ, NULL, OPEN_EXISTI

          NG, FILE_FLAG_DELETE_ON_CLOSE, NULL);

          // Spawn the clone EXE passing it our EXE's process handle

          // and the full path name to the Original EXE file.

          TCHAR szCmdLine[512];

          HANDLE hProcessOrig = OpenProcess(SYNCHRONIZE, TRUE, GetCurrentProcessId());


        上一頁 1 2 下一頁

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 平阳县| 柳州市| 盘山县| 阿尔山市| 名山县| 龙泉市| 三河市| 即墨市| 河南省| 深水埗区| 盐池县| 手游| 营口市| 册亨县| 洛川县| 盐亭县| 大渡口区| 龙泉市| 普陀区| 合肥市| 周宁县| 静乐县| 华坪县| 怀化市| 和林格尔县| 牟定县| 响水县| 林西县| 北辰区| 焦作市| 神池县| 佛冈县| 新竹县| 东平县| 固原市| 新民市| 石台县| 资源县| 左贡县| 隆化县| 永康市|