Monday, October 31, 2011

Jesso busts a Madras Mom - Explaining the cnbc scam

One of my friends in facebook just put this on his status,

 "are you serious about starting your own business in 2011? you have to check this out - http://t.co/q4bfMkga"

Now, if you visit this link it takes you to "http://www.cnbc.com-id.us/t/?blabla=1?t=38627"

Which is CNBC, the CNBC we all know, or wait is it really???

Let me break the URL apart.

"http://www.cnbc.com-id.us/" Note the bold part. So, really the website is NOT cnbc.com

To be clear "http://www.cnbc.com-id.us/" is NOT EQUAL TO http://www.cnbc.com

Why not?

well the extension  -id.us shows us that it is something like http://developers.facebook.com. So, facebook could similarly very well have something like google.com.facebook.com/ It would still belong to facebook. Things don't end at .com, if that is not the last thing in the address bar.

So google has something like mail.google.com, that is mail in google's domain. Similarly google could have named google plus as facebook.com-google.com!!! It would go to google's servers.

The scam site is really *cnbc* in "com-id.us" domain. Well, this is the one line which really matters...
To make the scam complete all the hyperlinks point to the real cnbc.com BUT all the links which are related to the scam go to http://www.cnbc.com-featured.us/

But for people who took so much pain, the real joke is Patrica Feeney - Madras Mom, come on, how about Chennai Mom, Ooops, I'm sorry I just found out that there is some Madras in Jefferson County in Oregon, but to find other Chennai guys dreaming of making big bucks sitting in your home or just dreaming about seeing Patrica Feeney in your neighborhood, sorry...

Using ctime

Well gprof is saying the factorial is quite fast, execution time is 0, so, I'll roll out my own time keeper,

Now, the main function is modified as,

int main(void)
{
        int number,result;
        time_t startTime,endTime;

        printf("\nEnter number: ");
        scanf("%d",&number);

        time(&startTime);

        result = factorial(number);
        time(&endTime);

        printf("\nStart Time: %d\nEnd Time: %d\n%d! = %d",startTime,endTime,number,result);
        printf("\nTime for calculation: %d",difftime(endTime,startTime));

        return 0;
}

Executing I get,

Enter number: 19

Start Time: 1320051528
End Time: 1320051528
12! = 479001600
Time for calculation: 0

Bad, bad factorial is too simple... A better challenge is needed....

Flogging factorial

I have decided to post atleast once per day, so for want of a better topic, I am going to write a simple factorial program in C and flog it to death. Well here we go, let me start with a childish

#include
int main(void) 

       int number, i = 1,result=1; 
       printf("\nEnter number: "); 
       scanf("%d",&number); 
       for(i=1;i<=number;i++) result = result*i; 
       printf("%d! = %d",number,result); 
       return 0; 

Simple, but if i want to use gprof to profile, i need to put the code for factorial in a separate function.

So, 

#include
int factorial(int n) 

    int i=1, result = 1; 
    for(i=1;i<=n;i++)result = result*i; 
    return result; 


int main(void) 

    int number; 
    printf("\nEnter number: "); 
    scanf("%d",&number); 
    printf("%d! = %d",number,factorial(number)); 
    return 0; 


And compile using cc -o flogFact flogFactorial.c -g -pg 

Well, after running  ./flogFact I get the gmon.out 

Now let me run gprof flogFact 
judge@boss:~/delete$ gprof flogFact -b 

Flat profile: Each sample counts as 0.01 seconds. 
no time accumulated 

% cumulative self                 self total 
time    seconds    seconds    calls    Ts/call    Ts/call   name 
0.00     0.00          0.00           1           0.00       0.00       factorial 

Call graph granularity: each sample hit covers 4 byte(s) 
no time propagated 

index % time     self     children       called         name 
                           0.00     0.00              1/1              main [5] 
[1]            0.0      0.00     0.00              1                 factorial [1] ----------------------------------------------- 

Index by function name 

[1] factorial 

Shit, no useful info just as yet, grr.. some more stuff to do, but i'm off for lunch...