Strange problem in my new program, dealing with variables.

This is a discussion on Strange problem in my new program, dealing with variables. within the C Programming forums, part of the General Programming Boards category; Hey, so I've been writing this new program to help me run aircrack-ng a little faster. Here is what I ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    NE Washinton
    Posts
    38

    Question Strange problem in my new program, dealing with variables.

    Hey, so I've been writing this new program to help me run aircrack-ng a little faster. Here is what I have thus far.
    Code:
    #include <stdio.h>
    int main()
    {
     char bssid[20];
     char essid[20];
     int channel;
     printf("AP BSSID:");
     fgets(bssid,20,stdin);
     printf("AP ESSID:");
     fgets(essid,20,stdin);
     printf("AP CHANNEL:");
     scanf("%d",&channel);
     printf("sudo airodump-ng -c %d -d %s -w %s mon0",&channel,bssid,essid);
     printf("sudo aireplay-ng -1 0 -e '%s' -a %s -h 00:19:7E:71:C0:2D mon0",essid,bssid);
     printf("sudo aireplay-ng -3 -b %s -h 00:19:7E:71:C0:2D mon0",bssid);
     printf("sudo aircrack-ng -z -b %s %s*.cap",bssid,essid);
     getchar();
     return 0;
    }
    Here is what I get when I input 00:11:22:33:44:55 for the BSSID FakeNet for the ESSID and 6 for the CHANNEL.
    Code:
    beatzz@hax0r:~$ ~/documents/c/./cracKrocKs
    AP BSSID:00:11:22:33:44:55
    AP ESSID:FakeNet
    AP CHANNEL:6
    sudo airodump-ng -c -1082094220 -d 00:11:22:33:44:55
     -w FakeNet
     mon0sudo aireplay-ng -1 0 -e 'FakeNet
    ' -a 00:11:22:33:44:55
     -h 00:19:7E:71:C0:2D mon0sudo aireplay-ng -3 -b 00:11:22:33:44:55
     -h 00:19:7E:71:C0:2D mon0sudo aircrack-ng -z -b 00:11:22:33:44:55
     FakeNet
    *.capbeatzz@hax0r:~$
    as you can see it dose not put each line of code on a line by itself, its all jumbled, and if u noticed, my channel number is ridiculously NOT what I assigned it. Any advice?

    P.S. Comment for the admins, I run aircrack-ng on my own home network, for security purposes
    Last edited by elsheepo; 03-07-2009 at 08:33 AM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,010
    fgets also reads the newlines (\n), so you may want to strip them...
    Also, when using %d, print does not expect the address of the argument to print, so don't pass a pointer - pass by value.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Location
    NE Washinton
    Posts
    38
    Okay, I fixed the pointer issues, but what did you mean about striping the \n newlines? I don't have any \n newlines

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,010
    You do, since fgets reads those (they're in the input buffer).
    It's the last character (before the \0 in the buffer).
    buf[ strlen(buf) - 1 ] = '\0';
    Should get rid of those.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Location
    NE Washinton
    Posts
    38
    Fixed it all! Thanks a bunch!
    Your answer guided me to the correct code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Setting environment variables for use outside program
    By guesst in forum Windows Programming
    Replies: 12
    Last Post: 09-09-2008, 01:53 PM
  2. Creating local variables in a program?
    By fl0at in forum C Programming
    Replies: 5
    Last Post: 01-04-2008, 07:34 PM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  4. Craps Program with Local Variables
    By tigrfire in forum C Programming
    Replies: 12
    Last Post: 11-09-2005, 09:01 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21