elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


  Mostrar Temas
Páginas: [1]
1  Programación / Programación C/C++ / Ayuda con getopt(), no me da el apuntador optarg en: 26 Noviembre 2015, 02:01 am
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <getopt.h>
#include <unistd.h>

using namespace std;

void usage(char* argv)
{
   cout << "usuario: " << argv << " -w /root/Desktop/123.bat -i 192.168.0.1 -p 666 -s C:\\users\\...."
    << endl;
   cout << endl << " -s direccion de carpeta de salida para windows" << endl;
   cout << " -w direccion a crear batch" << endl;
   cout << " -i direccion ip" << endl  << " -p puerto" << endl;
   cout << " -h Mostrar ayuda" << endl;
}

int main(int argc, char** argv)
{
   if(argc <= 1)
   {
      usage(argv[0]);
      return -1;
   }

   int opt, optchar;
   unsigned short int puerto;
   char* ip;
   string dirout, dirin, dirIp;
   while(optchar = getopt(argc, argv, "wspi:h:") != EOF)
   {
      switch(optchar)
      {
         case 'w':
         {
            dirout = optarg;
            break;
         }
         case 's':
         {
            dirin = optarg;   
            break;
         }
         case 'i':
         {
            ip = optarg;
            break;
         }
         case 'p':
         {
            puerto = atoi(optarg);
            break;
         }
         case '?':
         case 'h':
         {
            usage(argv[0]);   
            return -1;
         }
      }
   }
   
   string nomCarp = "";
   ofstream archivo(dirout.c_str(), ios_base::app);
   string batch = "@echo off"+ '\n';
   batch = batch +"if exist C:\\users\\%username%\\AppData\\Roaming\\" + nomCarp + "(goto :crearConexion)";
   batch = batch + "else (goto :crearCarpeta)\n";
   batch = batch + ":crearCarpeta" + '\n';
   batch = batch + "mkdir" + " "+ '\n';
   batch = batch + "move:";
   
   //archivo << batch;
   
   return 0;
}   
2  Programación / Programación C/C++ / Programa autoreplicable por la LAN...c++ en: 21 Julio 2015, 07:49 am
Hola quiero empezar un proyecto en c++ quiero hacer un autoejecutable que pueda replicarse por la LAN, quisiera ver si podrían darme ideas de como realizarlo, o algunos foros ya establecidos para el mismo tema..

Gracias..
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines