T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/lavocat.quebec/private_html/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.quebec/private_html/scripts/generate-network-certificates.js
const forge = require('node-forge');
const fs = require('fs');
const path = require('path');
const os = require('os');

// Get network interfaces to find the current IP
function getNetworkIPs() {
  const interfaces = os.networkInterfaces();
  const ips = ['127.0.0.1', 'localhost'];
  
  for (const name of Object.keys(interfaces)) {
    for (const iface of interfaces[name]) {
      // Skip internal and non-IPv4 addresses
      if (iface.family === 'IPv4' && !iface.internal) {
        ips.push(iface.address);
      }
    }
  }
  
  return ips;
}

function generateCertificates() {
  console.log('🔐 Generating HTTPS certificates for network access...');
  
  const ips = getNetworkIPs();
  console.log('📡 Detected network addresses:', ips);

  // Generate a key pair
  console.log('🔑 Generating RSA key pair...');
  const keys = forge.pki.rsa.generateKeyPair(2048);

  // Create a certificate
  console.log('📜 Creating certificate...');
  const cert = forge.pki.createCertificate();
  
  cert.publicKey = keys.publicKey;
  cert.serialNumber = '01';
  cert.validity.notBefore = new Date();
  cert.validity.notAfter = new Date();
  cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);

  // Certificate subject
  const attrs = [
    { name: 'countryName', value: 'CA' },
    { name: 'stateOrProvinceName', value: 'Quebec' },
    { name: 'localityName', value: 'Montreal' },
    { name: 'organizationName', value: 'LiberteMemeEnPrison Dev' },
    { name: 'organizationalUnitName', value: 'Development' },
    { name: 'commonName', value: 'localhost' }
  ];
  
  cert.setSubject(attrs);
  cert.setIssuer(attrs);

  // Add extensions for multiple hostnames/IPs
  const altNames = [];
  
  // Add DNS names
  altNames.push({ type: 2, value: 'localhost' });
  altNames.push({ type: 2, value: '*.localhost' });
  
  // Add IP addresses
  ips.forEach(ip => {
    if (ip !== 'localhost') {
      altNames.push({ type: 7, ip: ip });
    }
  });

  cert.setExtensions([
    {
      name: 'basicConstraints',
      cA: true
    },
    {
      name: 'keyUsage',
      keyCertSign: true,
      digitalSignature: true,
      nonRepudiation: true,
      keyEncipherment: true,
      dataEncipherment: true
    },
    {
      name: 'extKeyUsage',
      serverAuth: true,
      clientAuth: true,
      codeSigning: true,
      timeStamping: true
    },
    {
      name: 'nsCertType',
      client: true,
      server: true,
      email: true,
      objsign: true,
      sslCA: true,
      emailCA: true,
      objCA: true
    },
    {
      name: 'subjectAltName',
      altNames: altNames
    },
    {
      name: 'subjectKeyIdentifier'
    }
  ]);

  // Self-sign certificate
  cert.sign(keys.privateKey);

  // Convert to PEM format
  const certPem = forge.pki.certificateToPem(cert);
  const keyPem = forge.pki.privateKeyToPem(keys.privateKey);

  // Ensure certificates directory exists
  const certDir = path.join(__dirname, '..', 'certificates');
  if (!fs.existsSync(certDir)) {
    fs.mkdirSync(certDir, { recursive: true });
  }

  // Write certificates
  const certPath = path.join(certDir, 'network-cert.pem');
  const keyPath = path.join(certDir, 'network-key.pem');
  
  fs.writeFileSync(certPath, certPem);
  fs.writeFileSync(keyPath, keyPem);

  console.log('✅ Certificates generated successfully!');
  console.log('📁 Certificate files:');
  console.log(`   - Certificate: ${certPath}`);
  console.log(`   - Private Key: ${keyPath}`);
  console.log('');
  console.log('🌐 These certificates work with:');
  ips.forEach(ip => {
    console.log(`   - https://${ip}:3443`);
  });
  console.log('');
  console.log('⚠️  Browser Security Warning:');
  console.log('   You will see a security warning because this is a self-signed certificate.');
  console.log('   Click "Advanced" → "Proceed to [site] (unsafe)" to continue.');
  console.log('');
  console.log('🚀 To use these certificates, the server will automatically detect them.');
}

// Run the certificate generation
try {
  generateCertificates();
} catch (error) {
  console.error('❌ Error generating certificates:', error);
  process.exit(1);
}

CasperSecurity Mini