Saturday, December 26, 2015

Automation with system()

The system() function is kinda nice because you can call other programs or scripts from your program with it. Really you an do this with a BASH script so you don't need to write a compiled program. But the benefit here is you can write a program and add it to /usr/bin/ and then run it from then run it. So you can create your own commands essentially. You can also do this with the alias command. Something like this:

alias airecord="ifconfig wlan0 down && macchanger -r wlan0 && ifconfig wlan0 up && gnome-terminal -e airodump-ng -w record mon0"
Also bear in mind there are aleady automated tools for cracking wifi like wifite. That's not really the point. The point is that you might have to make system calls from a program. It can save a lot of coding. Like say you want to download a zip file, extract, and run it. You can do that one line of BASH that you can call from within your program. So it's useful if you want to keep your program as small as possible. You just have to make sure that the program that you are calling is installed.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
system("ifconfig wlan0 down");
system("macchanger -r wlan0");
system("ifconfig wlan0 up");
system("airmon-ng start wlan0");
system("gnome-terminal -e \"airodump-ng mon0\" \" && gnome-terminal -e airodump-ng mon0\"");
    return 0;
}

No comments:

Post a Comment