Beispiel #1
0
int scantext_extract_ats(unsigned char *buf, int len)
{
	/* alphanumeric and "-_.@!$"; 1=valid e-mail char, 2=invalid only at start/end */
	static const unsigned char mail_chars[256] = {
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,2,0,0,0,0,0,0,0,0,0,0,0,2,2,0,
		1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
		2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
		1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,2,
		0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
		1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	};
	struct maillist_t *root, *top;
	int i, j, st_i, end_i, mail_len;
	int found;
	char out_buf[256];

	root = top = NULL;
	for (i=0,found=0; i<len; i++) {
		if (buf[i] != '@') continue;

		for (st_i=i; st_i>0; st_i--)
			if (mail_chars[buf[st_i-1]] == 0) break;
		for (end_i=i+1; end_i<len; end_i++)
			if (mail_chars[buf[end_i]] == 0) break;

		for (; st_i<end_i; st_i++)
			if (mail_chars[buf[st_i]] != 2) break;
		if (((st_i+3) >= end_i) || (st_i >= i)) continue;
		for (; end_i > st_i; end_i--)
			if (mail_chars[buf[end_i-1]] != 2) break;
		if ((end_i <= (st_i+3)) || (end_i <= i)) continue;

		mail_len = end_i - st_i;
		if (mail_len < 7) continue;	/* [email protected] */

		found++;
		for (j=0; (j < (sizeof(out_buf)-2)) && (j < mail_len); j++)
			out_buf[j] = buf[st_i+j];
		out_buf[j] = 0;
		scan_out(out_buf);
	}

	return found;
}
Beispiel #2
0
/*
 * for each word, print up to 10 chars in big letters.
 */
int
main(int argc __unused, char *argv[])
{
	char word[10+1];			/* strings limited to 10 chars */

	while (*++argv) {
		strlcpy(word, *argv, sizeof (word));
		scan_out(1, word, '\0');
	}
	exit(0);
}
Beispiel #3
0
static int scan_wab(const char *filename)
{
	HANDLE hFile, hMap;
	DWORD cnt, base1, maxsize, i;
	register DWORD b, j;
	unsigned char *ptr;
	char email[128];

	hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
			NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile == NULL || hFile == INVALID_HANDLE_VALUE) return 1;
	maxsize = GetFileSize(hFile, NULL);

	hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
	if (hMap == NULL || hMap == INVALID_HANDLE_VALUE) {
		CloseHandle(hFile);
		return 2;
	}

	ptr = (unsigned char *)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
	if (ptr == NULL) {
		CloseHandle(hMap);
		CloseHandle(hFile);
		return 3;
	}

	base1 = *((DWORD *)(ptr + 0x60));
	cnt = *((DWORD *)(ptr + 0x64));

	for (i=0; i<cnt; i++) {
		b = base1 + i * 68;
		memset(email, '\0', sizeof(email));
		for (j=0; (b < maxsize) && (j < 68); j++, b+=2) {
			email[j] = ptr[b];
			if (ptr[b] == 0) break;
		}
		if (j > 0)
			scan_out(email);
	}

	UnmapViewOfFile(ptr);
	CloseHandle(hMap);
	CloseHandle(hFile);
	return 0;
}