新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 程序運行之后把自己刪除的方法

        程序運行之后把自己刪除的方法

        作者: 時間:2010-09-13 來源:網(wǎng)絡(luò) 收藏

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

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

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

          大家都知道,一般的程序的時候,可執(zhí)行文件本身是被操作系統(tǒng)保護(hù)的,不能用改寫的方式訪問,更別提在本身還在運行的時侯了。在Lu0的主頁上看到一種UNDOCUMENT的,通過改變系統(tǒng)底層的文件訪問模式實現(xiàn)刪除自己,那是實在功夫。我看了很是佩服。但是有沒有一種用在MSDN上就能查到的函數(shù)實現(xiàn)呢?有!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)鍵詞: 刪除 方法 自己 之后 運行 程序

        評論


        相關(guān)推薦

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

        關(guān)閉
        主站蜘蛛池模板: 旺苍县| 陕西省| 微博| 芜湖市| 特克斯县| 忻城县| 思南县| 广饶县| 宁夏| 阳谷县| 无棣县| 裕民县| 灵丘县| 茂名市| 钟祥市| 于田县| 威信县| 重庆市| 镇坪县| 梁河县| 霍城县| 玛沁县| 县级市| 平舆县| 卢湾区| 达拉特旗| 马边| 吉首市| 岫岩| 涟源市| 枞阳县| 泸定县| 大安市| 洪雅县| 勃利县| 汶上县| 高台县| 郎溪县| 陆川县| 石屏县| 苗栗县|