본문 바로가기

Research/Source Repository

Python string bruteforce 문자열 브루트포스가 필요할 때, 예를 들어 16진수로 이루어진 4글자의 브루트포스 스트링이 필요하다라면 import sysimport itertoolschoices = '0123456789abcdef'MaxLength = 4 f = open('res.txt', 'w')for length in range(0,MaxLength+1):for entry in itertools.product(choices,repeat = length):password = '0'*(MaxLength - length) password += ''.join(entry)print passwordf.write(password+'\n') f.close() 이렇게.혹 앞에 0 패딩을 빼고 싶으면 'password = '0'*(MaxLength.. 더보기
[C#] array byte to hex string static string Hex2Str(array b){ char * c = new char(b.GetLength()*2+2);byte a;c[0]='0';c[1]='x'; for(int i=0, j=0; i>4));c[j] = (char)( a>9 ? a+0x37:a+0x30);a= ((byte) (b[i]&0x0f));c[++j] = (char) (a>9?a+0x37:a+0x30);} return c;} 더보기
Variadic 매크로 VA_ARGS 매크로. 가변인자 형태의 매크로 또는 함수 정의. // variadic_macros.cpp #include #define EMPTY #define CHECK1(x, ...) if (!(x)) { printf(__VA_ARGS__); } #define CHECK2(x, ...) if ((x)) { printf(__VA_ARGS__); } #define CHECK3(...) { printf(__VA_ARGS__); } #define MACRO(s, ...) printf(s, __VA_ARGS__) int main() { CHECK1(0, "here %s %s %s", "are", "some", "varargs1(1)\n"); CHECK1(1, "here %s %s %s", "are", "som.. 더보기
ThreadPool simple example #define DELAY_COUNT 20 #define CACHE_LINE_SIZE 64 void CALLBACK Worker(PTP_CALLBACK_INSTANCE, PVOID, PTP_WORK); int workerDelay = DELAY_COUNT; DWORD tid[256]={0,}; __declspec(align(CACHE_LINE_SIZE)) typedef struct _THARG{ SRWLOCK SRWL; int threadNumber; unsigned int tasksToComplete; unsigned int tasksComplete; } THARG; int _tmain(DWORD argc, LPTSTR argv[]) { int nThread, iThread; HANDLE* pWorkOb.. 더보기
Mutex - Event Simple Code 뮤텍스 - 이벤트 사용 기본코드 DWORD _tmain(int argc, LPTSTR argv[]) { HANDLE hProduce, hConsume; mBlock.mGuard = CreateMutex(NULL, FALSE, NULL); // 두번째 인자가 TRUE 이면 생성 즉시 뮤텍스 할당 mBlock.mReady = CreateEvent(NULL, FALSE, FALSE, NULL); //mBlock.mReady = CreateEvent(NULL, TRUE, FALSE, NULL); // 두번째 인자 ManualReset 가 TRUE 이면 수동 재설정 이벤트(All Thread Signaled)-셋이벤트 후 계속 signaled 상태로 남음. FALSE 이면 자동으로 ResetEvent. // 세번.. 더보기
simple critical section 크리티컬 섹션 기본코드 typedef struct MSG_BLOCK_TAG { CRITICAL_SECTION mGuard; DWORD fReady, fStop; volatile DWORD nCons, mSequence; DWORD nLost; time_t mTimestamp; DWORD mChecksum; DWORD mData[DATA_SIZE]; } MSG_BLOCK; DWORD WINAPI Produce (void *arg) { srand ((DWORD)time(NULL)); while (!mBlock.fStop) { Sleep(rand()/100); EnterCriticalSection (&mBlock.mGuard); __try { if (!mBlock.fStop) { mBlock.fReady = .. 더보기
[Source] Timep.c 1. 운영체제 종류 확인 2. Argument 패스용 함수 _SkipArg 3. 실행시간 측정 (GetSystemTime) #include #include LPTSTR _SkipArg(LPCTSTR targv) { LPTSTR p = (LPTSTR)targv; while( *p != '\0' && *p != '\t' && *p != 0x20 ) p++; while( *p != '\0' && ( *p == '\t' || *p == 0x20 ) ) p++; return p; } int _tmain(int argc, LPTSTR argv[]){ STARTUPINFO StartUp; PROCESS_INFORMATION ProcInfo; union{ LONGLONG li; FILETIME ft; } CreateT.. 더보기
Windows System Programming Windows System Programming(J M Hart 저)을 읽는 중이다.좋은 코드들이 많고, 평소에 쓸 수 있을 만한 API들이 몇 가지가 있다.기록 할 겸사겸사.. 한동안은 이 책에서 소스코드를 보고 분석하고 올려두고 다시보고 수정하고 기타등등..예정.원본은 저자의 홈페이지에 있으니 참조하도록 하좌. Source script Test int main(void) { puts ("Hello You!"); return 0; } 더보기