Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-05

MAC Address on Linux

18 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé

Hi, does anyone knows how to get the MAC address of a NIC using Lazarus/FPC on Linux?.

P.S.: I found plenty of examples using Delphi's "Nb30" unit, only for Windows.

Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979

Reply by email

Leonardo M. Ramé
to silvioprog

El lun, 10-05-2010 a las 16:22 -0300, silvioprog escribi?:

Show quoted text 14 lines
Em 10-05-2010 16:12, Graeme Geldenhuys escreveu: > 2010/5/10 Leonardo M. : >> Hi, does anyone knows how to get the MAC address of a NIC using >> Lazarus/FPC on Linux?. > > I think the OnGuard components do this. You can find the download url > from the wiki page. > > http://wiki.lazarus.freepascal.org/OnGuard Or: http://www.silvioprog.com.br/dicas/pegaromacaddress ;)

Thanks!.

I'm looking for this because I'm trying to implement a licensing system to one of my products. I use it in a Delphi app and it works ok, now I'm trying to implement it for Linux. The system is this:

1) Get the MAC Address of the 1st enabled NIC, then encrypt using Rdl.
2) The user sends this encrypted string and we decrypt it to get it's MAC Address, then encrypt it again using Bf method.
3) The user has to insert this new string in the system, and it compares its MAC encrypted this time using Bf against the string the user entered, if they are equals then the license is ok.

This methods guarranties us that the software cannot be used in another machine (it's a server product).

Bf and Rdl are encryption methods used in TurboPower LockBox.

Which method do you use for licensing?

Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979

Reply by email

silvioprog
to Leonardo M. Ramé
Leonardo M. Ram? wrote 19 lines
Thanks!. I'm looking for this because I'm trying to implement a licensing system to one of my products. I use it in a Delphi app and it works ok, now I'm trying to implement it for Linux. The system is this: 1) Get the MAC Address of the 1st enabled NIC, then encrypt using Rdl. 2) The user sends this encrypted string and we decrypt it to get it's MAC Address, then encrypt it again using Bf method. 3) The user has to insert this new string in the system, and it compares its MAC encrypted this time using Bf against the string the user entered, if they are equals then the license is ok. This methods guarranties us that the software cannot be used in another machine (it's a server product). Bf and Rdl are encryption methods used in TurboPower LockBox. Which method do you use for licensing?

I get various informations of PC (serial disk << more important, MacAddress...), cryptographer(MD5+SHA1 and more...) and do a control algorithm myself.

Do not talk like you do, because someone can break your algorithm.

Silvio Cl?cio - <http://silvioprog.com.br>

Reply by email

Leonardo M. Ramé
to silvioprog: Or: http://www.silvioprog.com.br/dicas/pegaromacaddress ;) Silvio Cl?cio -…

El lun, 10-05-2010 a las 16:22 -0300, silvioprog escribi?:

Show quoted text 14 lines
Em 10-05-2010 16:12, Graeme Geldenhuys escreveu: > 2010/5/10 Leonardo M. : >> Hi, does anyone knows how to get the MAC address of a NIC using >> Lazarus/FPC on Linux?. > > I think the OnGuard components do this. You can find the download url > from the wiki page. > > http://wiki.lazarus.freepascal.org/OnGuard Or: http://www.silvioprog.com.br/dicas/pegaromacaddress ;)

Thanks!.

I'm looking for this because I'm trying to implement a licensing system to one of my products. I use it in a Delphi app and it works ok, now I'm trying to implement it for Linux. The system is this:

1) Get the MAC Address of the 1st enabled NIC, then encrypt using Rdl.
2) The user sends this encrypted string and we decrypt it to get it's MAC Address, then encrypt it again using Bf method.
3) The user has to insert this new string in the system, and it compares its MAC encrypted this time using Bf against the string the user entered, if they are equals then the license is ok.

This methods guarranties us that the software cannot be used in another machine (it's a server product).

Bf and Rdl are encryption methods used in TurboPower LockBox.

Which method do you use for licensing?

Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979

Reply by email

ik
to Leonardo M. Ramé: Hi, does anyone knows how to get the MAC address of a NIC using Lazarus/FPC on Linux?.…

Here is a simple example on how to read device MAC address in Linux

{$mode objfpc}
program get_mac;
uses sysutils;
const
  linux_path     = '/sys/class/net/%s/address';
  default_device = 'eth0';
var
  f       : textfile;
  device,
  path,
  addr    : string;
begin
  device := default_device;
  if (ParamCount = 1) then
    begin
        device := ParamStr(1);
    end;
   path := Format(linux_path,[device]);
   if Not FileExists(path) then
     begin
       writeln('Could not find the device: ', device);
       halt(1);
     end;
  AssignFile(f, path);
  reset(f);
  readln(f,addr);
  closefile(f);
  writeln(device, ' MAC Address: ', addr);
end.

Ido
http://ik.homelinux.org/

2010/5/10 Leonardo M.

Show quoted text 18 lines
Hi, does anyone knows how to get the MAC address of a NIC using Lazarus/FPC on Linux?. P.S.: I found plenty of examples using Delphi's "Nb30" unit, only for Windows. -- Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979 -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100510/d4978994/attachment.html>

Reply by email

silvioprog
to ik
ik wrote 41 lines
Here is a simple example on how to read device MAC address in Linux {$mode objfpc} program get_mac; uses sysutils; const linux_path = '/sys/class/net/%s/address'; default_device = 'eth0'; var f : textfile; device, path, addr : string; begin device := default_device; if (ParamCount = 1) then begin device := ParamStr(1); end; path := Format(linux_path,[device]); if Not FileExists(path) then begin writeln('Could not find the device: ', device); halt(1); end; AssignFile(f, path); reset(f); readln(f,addr); closefile(f); writeln(device, ' MAC Address: ', addr); end. Ido http://ik.homelinux.org/

Worked perfectely on Ubuntu 10.04. Thanks Ido ;)

Silvio Cl?cio - <http://silvioprog.com.br>

Reply by email

silvioprog
to Leonardo M. Ramé
Leonardo M. Ram? wrote 5 lines
El lun, 10-05-2010 a las 23:54 +0300, ik escribi?: > Here is a simple example on how to read device MAC address in Linux Thanks IK, Silvio and Graeme. I posted a reply but I think it was moderated :(. I don't know why, maybe because it contains links?.

Hm... I replied, and I received this: "Lazarus post acknowledgement".

Silvio Cl?cio - <http://silvioprog.com.br>

Reply by email

Brad Campbell
to silvioprog: I get various informations of PC (serial disk << more important, MacAddress...),…
silvioprog wrote 6 lines
I get various informations of PC (serial disk << more important, MacAddress...), cryptographer(MD5+SHA1 and more...) and do a control algorithm myself. Do not talk like you do, because someone can break your algorithm.

Security by obscurity is no most instances it's far easier to patch it out than break it.

Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Michael Schnell
to Leonardo M. Ramé: El lun, 10-05-2010 a las 16:22 -0300, silvioprog escribi?: Thanks!. I'm looking for this…
Leonardo M. Ram? wrote
I'm looking for this because I'm trying to implement a licensing system

IMHO the only decent licensing system, that
- is (quite) safe against abuse
- does not impose a great possibility to unwillingly disallow a licensed customer to use the product
- does not impose an annoying amount of additional maintenance work to the customer (portable between PCs without any effort)
- does not impose an annoying amount of additional maintenance work to the supplier
- provides cross platform licenses

is using a USB dongle that is loadable with licensees for multiple products by multiple vendors. (AFAIK, the hardware available is by multiple companies) This is very common e.e. in the Music Software busyness (mostly Windows and Mac based products)

IMHO any software that is so cheap that it does not make sense to use a hardware dongle is not viable to be protected against miss-use by any technical means.

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell

2010/5/11 Michael Schnell :

is using a USB dongle that is loadable with licensees for multiple products by multiple vendors. (AFAIK, the hardware available is by

...and often way to expensive or simply not feasible. Our software product runs on 20,000+ systems. Many of them are public schools. We are constantly trying to reduce the cost of running our systems (hence the push towards Linux), so introducing a hardware device for licensing with just push up the price again (or could be stolen in schools). :-/

Software-only licensing system is cheaper, more flexible and cannot be stolen - but has its negative side too (like maybe not being as secure as a hardware device).

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Henry Vermaak
to Michael Schnell
Michael Schnell wrote
On 05/11/2010 12:19 PM, Graeme Geldenhuys wrote: > Many of them are public schools. If I would be a manager of a school, I would not use any non-open source software anyway.

Please keep your opinion to yourself if it's not related to the topic of the list.

Henry

Reply by email

Michael Schnell
to Leonardo M. Ramé: El lun, 10-05-2010 a las 16:22 -0300, silvioprog escribi?: Thanks!. I'm looking for this…
Leonardo M. Ram? wrote
I'm looking for this because I'm trying to implement a licensing system

It does not make much sense to use the MAC address for enforcing a license. The MAC address the card uses can be configured in the System setup to be any value desired. Even in a Network, it's no problem using the same MAC address if the PCs dwell in different subnets.

-Michael

Reply by email

silvioprog
to Graeme Geldenhuys: 2010/5/11 Michael Schnell : ...and often way to expensive or simply not feasible. Our…
Graeme Geldenhuys wrote
2010/5/11 Michael Schnell : > is using a USB dongle that is loadable with licensees for multiple > products by multiple vendors. (AFAIK, the hardware available is by

I worked with electronics, I was thinking about creating a USB hardlock, but soon saw that not be worth(costs) creating something with hardware, at least here in Brazil (Except if I had at least 1,000 pieces with guaranteed sale).

Show quoted text 10 lines
...and often way to expensive or simply not feasible. Our software product runs on 20,000+ systems. Many of them are public schools. We are constantly trying to reduce the cost of running our systems (hence the push towards Linux), so introducing a hardware device for licensing with just push up the price again (or could be stolen in schools). :-/ Software-only licensing system is cheaper, more flexible and cannot be stolen - but has its negative side too (like maybe not being as secure as a hardware device).

I agree to use software. Nothing is 100% safe (even with hardlock).

Silvio Cl?cio - <http://silvioprog.com.br>

Reply by email