我正在编写一个程序来检测网络钓鱼。我正在尝试检查 URL 的基础是否在标签中相同。例如在 http://maps.google.com"> www.maps.yahoo.com 我试图检查 URL 的最后 2 部分是否相同,即 google.com = yahoo.com 或不是。
我正在使用以下代码来执行此操作:
void checkBase(char *add1, char *add2){
char *base1[100], *base2[100];
int count1 = 0, count2 = 0;
base1[count1] = strtok(add1, ".");
while(base1[count1] != NULL){
count1++;
base1[count1] = strtok(NULL, ".");
}
base2[count2] = strtok(add2, ".");
while(base2[count2] != NULL){
count2++;
base2[count2] = strtok(NULL, ".");
}
if((base1[count1-1] != base2[count2-1]) && (base1[count1-2] != base2[count2-2])){
cout << "Bases do not match: " << endl
<< base1[count1-2] << "." << base1[count1-1] << " and "
<< base2[count2-2] << "." << base2[count2-1] << endl;
}
else{
cout << "Bases match: " << endl
<< base1[count1-2] << "." << base1[count1-1] << " and "
<< base2[count2-2] << "." << base2[count2-1] << endl;
}
}
我不确定我在 if 语句中的比较是否正确。我正在传递两个 URL。谢谢