Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Don't ask to ask, just ask
 
PerlMonks  

Can Perl read CPU id?

by Nik
on Feb 09, 2005 at 21:41 UTC ( #429522=perlquestion: print w/ replies, xml ) Need Help??
Nik has asked for the wisdom of the Perl Monks concerning the following question:

Is there a perl script that can read the cpu id of the computer that runs the specific perl script so in that way the program can keep track of how many times the program have been run from the specific pc?

Is this possible please?

And also if it is is there a way also to spoof the cpu id liek we do with mac addresses? I'm sure that you could write a program that would listen for requests for the cpu id and then would feed it's own pre-determined cpu id?

Comment on Can Perl read CPU id?
Re: Can Perl read CPU id?
by dragonchild (Archbishop) on Feb 09, 2005 at 22:30 UTC
    Yes, and yes.

    As for the specifics for the party of the first part ... Perl can do access use any code that has been written in any language. Look at Inline.

    As for the specifics for the party of the second part ... the spoof is going to be accessor-specific, just like MAC address spoofing is.

    An aside: you really need to learn a few things.

    • Spelling
    • Grammar
    • Subtlety

    While English may or may not be your first language, you write as if you're a street punk. That won't win you many friends among the people whose knowledge you want to mine.

    Update: Fixed grammatical error per g0n's reply.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      No offence Dragonchild, but this:
      Perl can do access any code...
      isn't particularly grammatically correct either.

      VGhpcyBtZXNzYWdlIGludGVudGlvbmFsbHkgcG9pbnRsZXNz
      Whats wrong with my post? He is likely using one of the 3 methods: 1. Assembly Nothing i can do. 2. Registry Change the registry 3. Kernel function (This is the method I would used to get the CPUID if I were a real programmer) I wouild replace the SystemGetInfo function in KERNEL32.DLL with my own function. This would be a very difficult since my function would have duplicate all of the other functionality of this function as well. I don't believe that the telnet server can find out anything about your computer other than the IP address and MAC address if the client on the other side does not send that information. Simple telnet clients and programs written by others are not likely to send any additional information to the web server. On the other hand, if you use the timestamp program with any of these clients, it is written by his app and could possibly be sending extra information to the web server.
        The point is that it seems that you think there's a way to do this in some other language. Perl can link to code written in any language, therefore use whatever method exists in that other language via Inline.

        In this case, you say that there is a SystemGetInfo() function within KERNEL32.DLL. Since you're using a Win32 system, the Win32 family of modules may be appropriate. If, however, they didn't exist, you could use Inline::C to call the SystemGetInfo() function (assuming, of course, that KERNEL32.DLL is written in C).

        If, however, you are attempting to get the CPUID of a computer that is accessing your server via some protocol (such as telnet or http/https), that is called "hacking" by the US government and is punishable by serious jailtime. (More jailtime, in fact, than most murders.) I would rethink what it is you're trying to do. Maybe if you were to explain why you want this information, we could provide you with some alternatives.

        Being right, does not endow the right to be rude; politeness costs nothing.
        Being unknowing, is not the same as being stupid.
        Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
        Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      Can you please paste me the code that actually reads the cpu id and change it to an accesor-like? whats this anyway??!?
        D00d. I have a Perl program, it generates credit card numbers; this is similar in function to dealing with the CPU IDs. You'd have to just alter some of the c0de. Download it right here.

Re: Can Perl read CPU id?
by gellyfish (Monsignor) on Feb 10, 2005 at 09:22 UTC

    If this is the same thing that you have been banging on about without actually listening to what you have been told (like OT: Unique identification of a visitors pc), then the answer is again NO YOU CAN'T you cannot retrieve arbitrary information for a remote computer in a CGI program. Besides not all computers have a CPU which has a "CPU ID" and some CPUs allow you to turn it off or change it.

    /J\

      Well thats not the case here! i kno i asked that many times! Are you implying that i cannot retrive that kind of info for a remote computer from a cgi program bu i can though retrive that kind of info from a perl non-cgi program?!? If so. how?!!
Re: Can Perl read CPU id?
by fglock (Vicar) on Feb 10, 2005 at 20:01 UTC

    Is there a perl script that can read the cpu id of the computer that runs the specific perl script

    This works for me - Install this script in the cgi directory in the server, and you will be able to read the cpu id using a browser (note: you must install the "cpuid" executable)

    #! /usr/bin/perl use strict; print "Content-type: text/plain\n\n"; print `cpuid`;

    is there a way also to spoof the cpu id

    Sure. Just use this other script instead:

    #! /usr/bin/perl use strict; print "Content-type: text/plain\n\n"; print <<EOT; eax in eax ebx ecx edx 00000000 00000002 756e6547 6c65746e 49656e69 00000001 00000f29 0602080b 00004400 bfebfbff 00000002 665b5001 00000000 00000000 007b7040 80000000 80000004 00000000 00000000 00000000 80000001 00000000 00000000 00000000 00000000 80000002 20202020 20202020 20202020 20202020 80000003 6e492020 286c6574 58202952 286e6f65 80000004 20294d54 20555043 36302e33 007a4847 Vendor ID: "GenuineIntel"; CPUID level 2 Intel-specific functions: Version 00000f29: Type 0 - Original OEM Family 15 - Pentium 4 Extended family 0 Model 2 - Stepping 9 Reserved 0 Brand index: 11 [not in table] Extended brand string: " Intel(R) Xeon(TM) CPU 3.06GH +z" CLFLUSH instruction cache line size: 8 Initial APIC ID: 6 Hyper threading siblings: 2 [cut] EOT
      This is why i asked!

      Well a friend of mine maked his own online chess server and he in order to paly chess with him i have o install a software that he developed. What he does from the program is running online machine query checks through his hand-made chess client i use to connect to his online chess server. He specifically searches fro cpu id. What i want to do is to make a perl prog that weill listen fro cpu id requests and then feed the querint app with false cpu id! He asked me if i have a way to overcome that and i said i could! actually we made a bet! I think of that because i cant change the cpu id like i do with mac address if i like because new mac address id can be applied to an ethernet card but new cpu id cannot be applied/overwriiten to the old one! at least, i think it cant! so i made the above thouh to just feed it wrong! is this possible through a perl app?!?! That is what i wanted to do in the first place!

        You will have to modify my second program a little. My program uses http. You have to find out which communication protocol the chess program implements, and use that.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://429522]
Approved by Revelation
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-04-17 07:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (441 votes), past polls