釣魚攻擊第一彈-釋放文件

釣魚攻擊第一彈-釋放文件

之後所有文章發至《熊貓安全》公眾號上

獲取當前路徑

#include <stdio.h>
#include "direct.h"
#define MAX_SIZE 255
int main(int argc, const char* argv[]) 
{
    char buf[MAX_SIZE];
    getcwd(buf, sizeof(buf));
    printf("current working directory : %s\n", buf);
    puts(buf);
    return 0;
}

釋放任意資源文件

  1. 首先把需要釋放的文件通過winhex打開,然後點擊編輯->複製所有->C源碼(C)
  2. VS 創建代碼->Windows桌面嚮導->靜態庫(.lib)
  3. 把第一步獲得的C代碼添加至項目頭文件中,新建頭文件MyFile.h

重命名為unsigned char Myfile,裏面的數據不能改。

新建源文件project.cpp,寫入以下內容

#include "Resour.h"
#include "Myfile.h"
#include <fstream>
using namespace std;

void MyWriteFile(int code,const char *FileName)
{
	ofstream ofs;
	if (code == 1)
	{
		ofs.open(Filename, ios_base::out | ios_base::binary);
		ofs.write((char*)Myfile, sizeof(Myfile));
		ofs.close();
	}
	else if (code == 2)
	{
		MessageBoxW(0, L"釋放dll", L"提示", 0);
	}
}

project.h

#pragma once
#include <Windows.h>

void MyWriteFile(int code,const char *FileName);

運行項目,會在Release目錄下生成一個Project1.lib。

​4.VS新建一個控制台應用,把project.h、Project1.lib放入目錄

導入project.h到頭文件,添加Project1.lib到依賴項

main函數代碼如下

#include <stdio.h>
#include "direct.h"
#include "project.h"
#pragma warning(disable:4996)
#define MAX_SIZE 255
int main()
{
    char buf[MAX_SIZE];
    const char *name = "\\test.pdf";
    //const char *filename;
    getcwd(buf, sizeof(buf));//獲取當前程序路徑
    //printf("current working directory : %s\n", buf);
    //puts(buf);"\\test.pdf"
    strcat(buf, name);//拼接文件名進路徑
    //printf("current working directory : %s\n", buf);
    //puts(buf);


    printf("你好");
    MyWriteFile(1, buf);
}

運行生成的程序,會在你程序當前路徑釋放一個test.pdf,該pdf即為你需要釋放的文件

結語

這玩意有什麼用呢,回歸標題**釣魚 **和 偽裝