Created
February 4, 2023 15:59
Cross Site Scripting Vulnerability Scanner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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