C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 10th, 2013, 08:38 PM
macaswell macaswell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2010
Posts: 49 macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 29 m 15 sec
Reputation Power: 13
Facebook
(should be trivial) GCC skipping arg vector conditions?

I have a simple program that is supposed to either do its thing or, given the correct arguments, return a flag so that the parent process (a much, much more complex and advanced program...) can decide whether this process (called a cell) is safe to run, or if it's been flagged as unsafe because a proprietary virus (part of this complex process) has infected this cell and marked it with the flag 0xBADF. Btw, I say virus because precisely what it does is act as a lytic or lysogenic process which either infects a "cell," giving it the flag that says the cell could be harmful/shouldn't be loaded or executed, or injects a copy of itself into a cell process so that the cell process could itself become one of these cell checker viruses. It's confusing, but I assure you that it does not even work without this framework I've developed. Anyway, my test cell file that I want to try to change the flag on won't even correctly work anyway.

The source is:
Code:
C
/* 
 * cf1.c
 * cell flag to test labeling for use in VAIS and other NOXIS classes
*/

#include<stdio.h>

int main(int argc, char** argv){
  if(argv[1] == "?"){
    if(argv[2] == "CELL_FLAG"){
      return 0x5afe; // 5AFE is safe
    }
  }else{
    printf("The default CELL_FLAG for this cell is 0x5AFE.\n");
    return 0;
  }
}


The command line is:
Code:
$ gcc -o cf1 cf1.c
$ ./cf1 ? CELL_FLAG


The process should return 0x5AFE, as denoted by the mac os x (I don't know if other unix systems use $?).

But instead, it ignores the input and does it's thing.

What's goin' on here?

EDIT: Just to clarify and ease your mind, I say "virus" but it's only a modified version of Jingle Bell, from this article:
http://www.kernelthread.com/publications/security/vunix.html

Reply With Quote
  #2  
Old March 10th, 2013, 08:48 PM
macaswell macaswell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2010
Posts: 49 macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 29 m 15 sec
Reputation Power: 13
Facebook
On another note, the same thing is happening to other processes with the argv conditions.

Reply With Quote
  #3  
Old March 10th, 2013, 09:00 PM
macaswell macaswell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2010
Posts: 49 macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level)macaswell User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 29 m 15 sec
Reputation Power: 13
Facebook
Sorry, it was extremely trivial. I need to use strcmp()...I'm switching between languages constantly and these things are always confused. Anyway, the fixed (and more proper) source code is:

Code:
c
#include<stdio.h>
#include<string.h>

int main(int argc, char** argv){
  while(argc > 1){
    if(strcmp(argv[1], "?") == 0){
      if(strcmp(argv[1], "CELL_FLAG") == 0){
        return 0x5afe; // 0x5AFE is safe
      }
    }
    break;
  }

  printf("The default CELL_FLAG for this cell is 0x5AFE.\n");
  return 0;
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > (should be trivial) GCC skipping arg vector conditions?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap