Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
126 changes: 126 additions & 0 deletions PDF/IMPROVEMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# XSS-PDF Generator Improvements

This document outlines the recent improvements made to the XSS-PDF Generator to address various issues and enhance functionality.

## Issues Addressed

### 1. ✅ Complete Payload Visibility in PDF Files
**Problem**: Entire payload was not visible in PDF files for reference - payloads were truncated and only showed partial content.

**Solution**:
- Enhanced `format_complete_payload_for_pdf()` function to display complete payloads
- Increased line length from 45 to 80 characters per line
- Removed artificial limits on payload display (was only showing first 8 lines)
- All payload content is now visible in the PDF for full reference

### 2. ✅ Filename as Heading in PDF Files
**Problem**: PDF files didn't show the filename for easy identification.

**Solution**:
- Added filename as a prominent heading in each PDF file
- Filename is displayed at the top in larger font (14pt)
- Format: "FILENAME: [actual_filename.pdf]"
- Makes it easy to identify which PDF file you're viewing

### 3. ✅ OS-Aware File System Targeting
**Problem**: Script used hardcoded file paths for all operating systems, causing inappropriate paths (e.g., Windows paths on Linux).

**Solution**:
- Added `get_os_specific_paths()` function with platform detection
- **Windows**: Targets `C:\Windows\System32\`, `C:\Users\`, etc.
- **macOS**: Targets `/Applications/`, `/Users/`, `/System/`, etc.
- **Linux**: Targets `/etc/passwd`, `/home/`, `/usr/bin/`, etc.
- **Android**: Targets `/system/`, `/data/`, Android-specific paths
- Automatic OS detection using `platform.system()`

### 4. ✅ Fixed "Parent Not Defined" Errors
**Problem**: Chrome DOM exploit payloads referenced `parent`, `top`, `frames` without checking if they exist, causing JavaScript errors.

**Solution**:
- Added proper existence checks: `if(typeof parent !== 'undefined' && parent.window)`
- Applied to all DOM manipulation payloads:
- `parent.window.location` checks
- `top.document` checks
- `frames[0]` checks
- `parent.postMessage` checks
- Graceful fallbacks when objects are undefined

### 5. ✅ Merged Payloads from Another-Script.py
**Problem**: Another-Script.py contained unique payloads that weren't in script.py.

**Solution**:
- Extracted unique payloads from Another-Script.py
- Integrated them into appropriate categories in script.py:
- Chrome DOM exploits
- Firefox browser-specific payloads
- File system access techniques
- Data exfiltration methods
- Maintained both scripts for different use cases

### 6. ✅ Organized PDF Folder Structure
**Problem**: XSS-PDF files were scattered in the root directory.

**Solution**:
- Created dedicated `PDF/` folder for all XSS-PDF related files
- Moved `script.py`, `Another-Script.py`, and `Files/` into `PDF/` directory
- Updated README.md with new folder structure and usage instructions
- Clean project organization with clear separation

## New Features Added

### Enhanced PDF Content Display
- **Complete payload visibility**: Full JavaScript payload shown in PDF
- **Filename integration**: PDF filename displayed as heading
- **Better formatting**: Improved line spacing and font sizes for readability

### Cross-Platform Compatibility
- **OS detection**: Automatic detection of Windows/Linux/macOS/Android
- **Platform-specific paths**: Appropriate file system paths for each OS
- **Universal payload support**: Works correctly across all supported platforms

### Improved Error Handling
- **Object existence checks**: Prevents "undefined" errors in browser contexts
- **Graceful fallbacks**: Continues execution even when parent objects are missing
- **Better browser compatibility**: Works in different JavaScript security contexts

## Testing Results

All improvements have been tested and verified:

✅ **Payload Visibility**: Complete payloads now visible in generated PDFs
✅ **Filename Headers**: Filenames properly displayed in PDF content
✅ **OS Detection**: Linux paths (`/etc/passwd`) correctly used on Linux system
✅ **Parent Checks**: No more "parent not defined" errors in payloads
✅ **Payload Merging**: Additional payloads from Another-Script.py integrated
✅ **Folder Structure**: All scripts work correctly in new PDF/ directory

## Usage Examples

```bash
# Navigate to PDF directory
cd PDF

# Generate Chrome payloads with OS-specific file paths
python3 script.py -b chrome --category file_system -u http://test.com

# Generate payloads with complete visibility and filename headers
python3 script.py -b firefox --count 5 -u http://evil.com -v

# Use alternative script for browser-specific PDFs
python3 Another-Script.py -b safari -u http://test.com
```

## File Structure After Improvements

```
XSS-PDF/
├── PDF/ # All XSS-PDF tools (NEW)
│ ├── script.py # Enhanced main generator
│ ├── Another-Script.py # Browser-specific generator
│ ├── Files/ # Generated PDF output directory
│ └── IMPROVEMENTS.md # This file
├── README.md # Updated documentation
└── other files...
```

All improvements maintain backward compatibility while significantly enhancing functionality and user experience.
Loading
Loading