yarg.command('open [file]', 'opens save file and returns data in the terminal', (yargs) => { yargs.positional('file', { type: 'string', describe: 'file to open' }) }, function(argv) { if(!argv) { console.log(`${logSymbols.warning} ${chalk.yellow('Please enter the name of the file you want to open')}`); } fs.access(`data/${argv.file}`, fs.F_OK, (err) => { if (err) throw err; fs.readFile(`data/${argv.file}`, 'utf8', (err1, data) => { if(err1) throw err1; let realdata = JSON.parse(data); for(let i = 0; i < realdata.array.length; i++) { let selected = realdata.array[i]; console.log(`${chalk.blue('ip:')} ${chalk.green(selected.ip)} ${chalk.blue('port:')} ${chalk.green(selected.port)} ${chalk.blue('success:')} ${selected.success == true ? chalk.green(selected.success) : chalk.red(selected.success)}`); } }) }); });
yarg.command('save [name]', 'saves previous scan permanently', (yargs) => { yargs.positional('name', { type: 'string', describe: 'name of the file in which your scan will be saved' }) }, function(argv) { if(!argv) { console.log(`${logSymbols.warning} ${chalk.yellow('Please enter the name for the file of the scan you want to save')}`); } fs.access('data/temporary.json', fs.F_OK, (err) => { if (err) throw err; fs.readFile('data/temporary.json', 'utf8', (err1, data) => { if (err1) throw err1; let realdata = JSON.parse(data); for(let i = 0; i < realdata.array.length; i++) { fs.writeFile(`data/${argv.name}.json`, realdata.array[i], (err2) => { if (err2) throw err2; console.log(`${chalk.blue('Your scan has been permanently saved in file:')} ${chalk.green(`${argv.name}.json`)}`) }); } }); }) });
console.log(`${logSymbols.warning} ${chalk.yellow('Please either provide the first, last or both range numbers')}`); } else if (argv.options == 'r' && argv.rangeFN <= 0 || argv.rangeSN > 65535) { console.log(`${logSymbols.warning} ${chalk.yellow('The first range number must be greater than 1 and the second number must be less than 65535')}`); } else { console.log(`${logSymbols.warning} ${chalk.yellow('Please give a valid scan type')}`)