Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 31st, 2004, 8:38 AM   #1
ckocabiyik1980
Newbie
 
Join Date: Aug 2004
Posts: 5
Rep Power: 0 ckocabiyik1980 is on a distinguished road
Hello, can you help me please? Is there a way to get the mainboard or ethernet card specific ID number (maybe a serial code) into my program. i want my code couldn't be executed on another machine, so i need to check the ethernet card ID and the motherboard id. Can I do it?
ckocabiyik1980 is offline   Reply With Quote
Old Aug 31st, 2004, 8:41 AM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
you might be able too using a windows api. Not sure which one. in linux i am sure it'll be easyer, there probally some enviroment varible that you could grab. Sorry can't help you more than that right now, just got to work and the coffe hasn't kicked in yet. i'll post some more help in a bit.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Aug 31st, 2004, 9:19 AM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Here take a look at this. Or you could even take a look at this.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Aug 31st, 2004, 9:39 AM   #4
ckocabiyik1980
Newbie
 
Join Date: Aug 2004
Posts: 5
Rep Power: 0 ckocabiyik1980 is on a distinguished road
Sorry, I forgot to say that i am using Red Hat 9.0 Linux distribution
ckocabiyik1980 is offline   Reply With Quote
Old Aug 31st, 2004, 10:04 AM   #5
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
that could have helped ;-)

try using dmesg to see if that's the info that you want. Then you can output what that command outputs into a text file like this

dmesg > data.txt

or you could do somthing like this to save some time in having to figure out what lines you want.

dmesg | grep -i 'etho' > data.txt

that would find any lines that contain eth0 (your ethernet card) from the dmesg command and dump them into a text file. Then all you'd have to do is read the text file.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Sep 1st, 2004, 9:10 AM   #6
ckocabiyik1980
Newbie
 
Join Date: Aug 2004
Posts: 5
Rep Power: 0 ckocabiyik1980 is on a distinguished road
Thanks for the helps, but i learnt that not every card supports an electronic serial number generation. I found an easy way to obtain the HDD serial number and use it for authentication.And i just wrote a simple program to implement "ls -l" command with HDD authentication. The code is below. Please send comments. Can this code be hacked easily?

[/code]/*
This program will print the folder contents of the program's working directory,
only on an authorized HDD. It will check the serial number of the HDD for this
purpose. In a matching case, it will call the UNIX system function "ls" to list
the folder contents. In the mismatch case, it will give an error message. and
exit. This program executes truely for HDDs havin' 8 character serial numbers like
Seagate HDDs, but can easily be edited to apply to other HDDs.

Second version of this program may be a "TRUE" or "FALSE" returning
program using UNIX sockets to communicate with another code.
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

int main(void)
{
FILE *fp; // File pointer for the file generated with "hdparm" system command
int c,j,k,i=0; // General counter variables
char hddparam[BUFSIZ]; // Array to hold the contents of the file
char hddsn[10]; // Array to hold the current disk's serial number (first 8 chars for this version)
char name[11]; // Array to hold the "SerialNo=" text string fetched from the file
char unique[]="ABCDEFGH"; // Required HDD serial number for the program to be executed

// Get HDD parameters to a text file under app's running dir
system("hdparm -i /dev/hda >hddsn.txt");

// Open the file to read
fp=fopen("hddsn.txt","r");

// If file cannot be opened, give error and exit
if(fp==NULL)
{
perror("File cannot be opened!\n");
exit(EXIT_FAILURE);
}

// Get HDD parameters from the generated file into a buffer
while((c=fgetc(fp))!=EOF)
{
hddparam[i]=c;
i++;
}

// Close the file
fclose(fp);

// Remove the file
system("rm -f hddsn.txt");

// Write serial no to the screen and decide what to do
for(i=0;i<strlen(hddparam);i++)
{
// Try to catch clues for the text "SerialNo=" in the buffer
if(hddparam[i]=='S')
{
if((hddparam[i+1]=='e')&&(hddparam[i+6]=='N')&&(hddparam[i+7]=='o')&&(hddparam[i+8]=='='))
{
// Clues are catched, get the string into an array
for(j=i,k=0;j<=i+8;j++,k++)
{
name[k]=hddparam[j];
}

// If the text is "SerialNo=", we are at the right point
if(strcmp(name,"SerialNo=")==0)
{
// Print the text
//printf("%s\n\n",name);

// Get 8 characters following "SerialNo=" from the buffer
// This is the unique HDD serial no for Seagate HDD's
// Not all disks have 8 character serial numbers, so the code
// will change if the system will be installed on a different
// HDD having a serial no in a different format
for(j=i+9,k=0;j<=i+16;j++,k++)
{
hddsn[k]=hddparam[j];
}

// Compare the serial number of the current HDD with the one
// that is unique for my system. Upon match print folder contents
if(strcmp(hddsn,unique)==0)
{
printf("Printing folder contents;\n");
system("ls -l --color");

// Exit
return 0;
}

// This part of the code will be executed if the HDD serial numbers
// don't match
else
{
printf("Error with the code;\n");
printf("**You are not allowed to see the folder contents on this machine**\n");

//Exit
return 0;
}

// Print the serial numbers of current disk and the authorized disk
//printf("This disk:\t%s\n",hddsn);
//printf("Required disk:\t%s\n",unique);
}
}
}
}
}[code]
ckocabiyik1980 is offline   Reply With Quote
Old Sep 1st, 2004, 9:28 AM   #7
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
i've read that that serial number that you're getting is generated when you create a new partition. Thus, if the user creates a new partition after installing your program, it'll have a different serial than at install time. Then again i have been knowen to be wrong and i havn't done that much programming in the area of grabbing hardware information.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Sep 1st, 2004, 9:36 AM   #8
ckocabiyik1980
Newbie
 
Join Date: Aug 2004
Posts: 5
Rep Power: 0 ckocabiyik1980 is on a distinguished road
Well, when i run this command in Linux;

/dev/hda:

 Model=ST380011A, FwRev=3.54, SerialNo=ABCDEFGH
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes: pio0 pio1 pio2 pio3 pio4 
 DMA modes: mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: ATA/ATAPI-6 T13 1410D revision 2: 1 2 3 4 5 6

So, Model is for a physical drive, right? Not for a partition i think. So serial no must be unique (I HOPE SO)
ckocabiyik1980 is offline   Reply With Quote
Old Sep 1st, 2004, 1:11 PM   #9
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
maybe, you'll jsut have to see when your done programming this program. The answer will show up in the testing phase of your programming.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:59 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC