Ejemplo n.º 1
0
DbPid *Db::newPid(pid_t pid) {
	assert(findPid(pid) == 0);
	
	DbPid *newpid = new DbPid(pid);
	if (!pidlist_)
		pidlist_ = newpid;
	else
		pidlist_->add(newpid);
		
	return newpid;
}
Ejemplo n.º 2
0
int main(int argc, char** argv)
{
	if(argc < 3)
		usage();

	long rsaptr = getRSAPointer(argv[1]);
	long hostptr = getHostPointer(argv[1]);

	printf("%lo   %lo", rsaptr, hostptr);

	int childpid = fork();
	if(childpid == -1)
		fatal("Unable to fork.");

	if(childpid == 0)
	{
		printf("I'm the child");
		//chdir(TIBIA_ENV);
		execl(TIBIA_PATH, (const char*) NULL, (char*) NULL);
		exit(0);
	}

	sleep(2);
	pid_t pid = findPid("Tibia");

	//write RSA key
	char data[310] = "";
	strcpy(data, RSA_KEY);
	writeMemory(pid, rsaptr, data, RSALEN);
	
	//DEBUG
	readMemory(pid, rsaptr, data, RSALEN);
	printf("rsa: %s\n", data);
	//DEBUG
	
	//read pointer to Hostname struct
	unsigned char ptrdata[4] = "";
	readMemory(pid, hostptr, ptrdata, 4);

	//read offset+4 on Hostname struct
	readMemory(pid, chartohex(ptrdata)+4, ptrdata, 4);
	char loc[26] = "";
   	strcpy(loc,argv[2]);
	int len = 26;
	writeMemory(pid, chartohex(ptrdata), loc, len); 

	readMemory(pid,chartohex(ptrdata), data, 30);
	printf("IP changed to: %s\n", data);

	return 1;
}
Ejemplo n.º 3
0
DbPid *Db::removePid(pid_t pid) {
	// find dbpid
	DbPid *dbpid = findPid(pid);
	if (!dbpid)
		return 0;
	
	// remove first element
	if (dbpid == pidlist_)
		pidlist_ = dbpid->getNext();
	else
		pidlist_->remove(dbpid);
	
	dbpid->resetNext();
	return dbpid;
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
    int pid = -1;
    char progname[128] = {0};
    int signal_number = -1, i, list_only = 0;

    for(i = 1; i < argc; i++)
    {
        if(argv[i][0] != '-')
        {
            usage();
            return (-1);
        }

        switch(argv[i][1])
        {
            case 'p':
                strncpy(progname, argv[++i], 128);
                progname[127] = '\0';
                break;
            case 's':
                signal_number = atoi(argv[++i]);
                break;
            case 'l':
                list_only = 1;
                break;
            default:
                usage();
                return -1;
        }
    }

    if(progname[0] == 0)
    {
        usage();
        return -1;
    }

    pid = findPid(progname);
    if(pid == -1)
    {
        fprintf(stderr, "no such program: %s\n", progname);
        return -1;
    }
    if(list_only)
    {
        fprintf(stdout, "PID: %d\n", pid);
        return 0;
    }

    if(signal_number != -1)
    {
        int result;

        result = kill(pid, signal_number);
        if(result == -1)
        {
            if(errno == EPERM)
            {
                char buf[256];

                fprintf(stderr, "operation not authorized, switching to root\n");
                snprintf(buf, 256, "kill -%d %d", signal_number, pid);
                if(execlp("kdesu", "kdesu", "-c", buf, (void *)0) == -1)
                {
                    fprintf(stderr, "operation failed: %s\n", strerror(errno));
                    return -1;
                }
            }
            else
            {
                fprintf(stderr, "operation failed (invalid signal or no such process)\n");
                return -1;
            }
        }
    }
    else
    {
        fprintf(stderr, "only signal sending is currently supported\n");
        return -1;
    }
    return 0;
}
Ejemplo n.º 5
0
int main( int argc, char **argv )
{
	char command[512];
	char filename[256], tmpFile[256];
	FILE *fsZip, *fsBin, *fsImg;
	uint8_t *bufferZip, *bufferBin, *pid, pidChecksum;
	size_t sizeZip, sizeBin;
	DWORD bytesWritten;
	char *directory, *path;
	STARTUPINFO si;
	PROCESS_INFORMATION pi;

	if (argc < 2)
	{
		puts("Usage: zipImage <binfile>");
		return waitBeforeQuit(-1);
	}

	//Get the filename without extension
	memset(filename, 0, 256);
	strncpy(filename, argv[1], (strrchr(argv[1], '.') - argv[1]));

	//Zip the *.bin file
	directory = (char*)calloc(sizeof(char), MAX_PATH);
	if (directory == NULL)
	{
		puts("Could not allocate memory for directory.");
		return waitBeforeQuit(-1);
	}

	bytesWritten = GetModuleFileName(NULL, directory, MAX_PATH);
	if (bytesWritten == 0)
	{
		free(directory);
		puts("Could not get current directory.");
		return waitBeforeQuit(-1);
	}
	
	path = (char*)calloc(sizeof(char), MAX_PATH);
	if (path == NULL)
	{
		free(directory);
		puts("Could not allocate memory for path.");
		return waitBeforeQuit(-1);
	}

	strncpy(path, directory, (strrchr(directory, '\\') - directory));
	sprintf(command, "%s\\zip.exe -j \"%s.zip\" \"%s\"", path, filename, argv[1]);
	free(directory);
	free(path);

	memset(&si, 0, sizeof(STARTUPINFO));
	memset(&pi, 0, sizeof(PROCESS_INFORMATION));
	si.cb = sizeof(si);

	if (!CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
	{
		puts("Unable to start zipImage process.");
		return waitBeforeQuit(-1);
	}
	WaitForSingleObject(pi.hProcess, INFINITE);

	CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);

	//Open the zip file
	memset(tmpFile, 0, 256);
	strncpy(tmpFile, filename, strlen(filename));
	strcat(tmpFile, ".zip");
	fsZip = fopen(tmpFile, "rb");
	if (fsZip == NULL)
	{
		puts("The specified zip file can not be opened!");
		return waitBeforeQuit(-1);
	}

	//Get the Zip size
	fseek(fsZip, 0, SEEK_END);
	sizeZip = ftell(fsZip);
	fseek(fsZip, 0, SEEK_SET);

	//Allocate a buffer to contain the content of the Zip file
	bufferZip = (uint8_t*)malloc(sizeZip * sizeof(uint8_t));
	if (bufferZip == NULL)
	{
		fclose(fsZip);
		printf("Error, no enough memory to open the specified file: %s\n", tmpFile);
		return waitBeforeQuit(-1);
	}

	//Read the whole Zip into the buffer
	fread(bufferZip, sizeof(uint8_t), sizeZip, fsZip);
	fclose(fsZip);

	//Remove the Zip file
	//remove(tmpFile);

	//Open the bin file
	fsBin = fopen(argv[1], "rb");
	if (fsBin == NULL)
	{
		puts("The specified bin file can not be opened!");
		free(bufferZip);
		return waitBeforeQuit(-1);
	}

	//Get the Bin size
	fseek(fsBin, 0, SEEK_END);
	sizeBin = ftell(fsBin);
	fseek(fsBin, 0, SEEK_SET);

	//Allocate a buffer to contain the content of the Bin file
	bufferBin = (uint8_t*)malloc(sizeBin * sizeof(uint8_t));
	if (bufferBin == NULL)
	{
		free(bufferZip);
		fclose(fsBin);
		printf("Error, no enough memory to open the specified file: %s\n", tmpFile);
		return waitBeforeQuit(-1);
	}

	//Read the whole Bin into the buffer
	fread(bufferBin, sizeof(uint8_t), sizeBin, fsBin);
	fclose(fsBin);

	//Try to find the pid
	if ((pid = findPid(bufferBin, sizeBin)) == NULL)
	{
		free(bufferBin);
		free(bufferZip);
		return waitBeforeQuit(-1);
	}

	pidChecksum = calculatePidChecksum(pid, bufferZip, sizeZip);
	printf("Pid Checksum after neg: %#02x\n", pidChecksum);
	pid[0x1FF] = pidChecksum;

	//Save everything as an *.img file
	memset(tmpFile, 0, 256);
	strncpy(tmpFile, filename, strlen(filename));
	strcat(tmpFile, ".img");
	fsImg = fopen(tmpFile, "wb");
	if (fsImg == NULL)
	{
		free(bufferBin);
		free(bufferZip);
		free(pid);
		puts("The specified img file could not be opened!");
		return waitBeforeQuit(-1);
	}

	//Write the pid
	fwrite(pid, sizeof(uint8_t), 0x200, fsImg);
	//Write the Zip content
	fwrite(bufferZip, sizeof(uint8_t), sizeZip, fsImg);
	fclose(fsImg);

	free(bufferZip);
	free(bufferBin);
	free(pid);

	if (calculateFileChecksum(tmpFile) == 0)
		printf("Success to build %s img!\n", filename);
	else
		puts("Error: Checksum fail!");

	return waitBeforeQuit(0);
}
Ejemplo n.º 6
0
int main(int argc, char *argv[]) {
    
    hashset_t set = hashset_create();
    hashset_add(set,"leer");
    curl_global_init(CURL_GLOBAL_ALL);
    CURL * myHandle = curl_easy_init();
    char md5Password [32];
    struct string s;
    struct string g;
    init_string(&s);
    init_string(&g);
    int i;
    /*
      char password[BUFSIZ];
      char name[BUFSIZ];
      printf("Enter Username: \n");
      fgets(name, BUFSIZ, stdin);
      printf("Enter Password: \n");
      fgets(password,BUFSIZ,stdin);
      cleaner(name);
      cleaner(password);
     */

    //temp
    char password [] = "569dgBAh#6Kv2^e9z^ALFiOq";
    char name [] = "Foxi";

    //temp

    hashPassword(password, md5Password);
    doLogin(name, md5Password, myHandle);

    sleep(3);
    getSecretToken(myHandle,&s);
    sleep(3);

    char* tokenarray = (char*) malloc((s.len + 3) * sizeof (char));

    strcpy(tokenarray, s.ptr);
    findSecretToken(tokenarray, s.len);
    
    //Hier muss die URL hin auf welche Danke gesagt wird!
    char danke [] = "http://usenet-4all.info/forum/showthread.php?t=637647";
    doTanks(danke,&g, myHandle);

    char* pidarray = (char*) malloc((g.len + 3) * sizeof (char));
    strcpy(pidarray, g.ptr);
    findPid(pidarray, g.len, set);
    //Ab hier habe ich alle PIDS!
    pushthanks(tokenarray,danke,set,myHandle);
    
    
    print_cookies(myHandle);
    curl_easy_cleanup(myHandle);

    free(s.ptr);

    free(tokenarray);
    free(pidarray);

    free(g.ptr);


    return 0;
}