Skip to content

Instantly share code, notes, and snippets.

@R3DHULK
Created February 4, 2023 15:59
Show Gist options
  • Save R3DHULK/7f88d467497f27b2cac879115b2a8ce0 to your computer and use it in GitHub Desktop.
Save R3DHULK/7f88d467497f27b2cac879115b2a8ce0 to your computer and use it in GitHub Desktop.
Cross Site Scripting Vulnerability Scanner
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PAYLOAD_LEN 100
int main(int argc, char *argv[])
{
char payload[PAYLOAD_LEN];
if (argc != 2) {
fprintf(stderr, "Usage: %s <input string>\n", argv[0]);
return 1;
}
strncpy(payload, argv[1], PAYLOAD_LEN);
if (strstr(payload, "<script>") != NULL || strstr(payload, "</script>") != NULL ||
strstr(payload, "<script src=") != NULL || strstr(payload, "<script type=") != NULL) {
printf(" [+] Possible XSS vulnerability found!\n");
} else if (strstr(payload, "<") != NULL && strstr(payload, ">") != NULL) {
printf("String contains HTML special characters, check for XSS vulnerability.\n");
} else {
printf(" [-] No XSS vulnerability found.\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment