Re: DB -> C++ -> XS/Swig -> DBI -> Perl
by salva (Canon) on Jan 29, 2014 at 11:09 UTC
|
You could fork the DBD source code for your particular database and replace the part where the connection is set up for some other that calls that C++ library.
It is difficult to give you a more detailed response without knowing the details (which database is being used, what do you get from that C++ library, etc.).
Maybe you could just open the binary object for that C++ library from Perl and use a couple of regular expressions to extract the database user and password! | [reply] |
Re: DB -> C++ -> XS/Swig -> DBI -> Perl
by Jenda (Abbot) on Jan 29, 2014 at 11:16 UTC
|
I think you'll have to provide more information. What database? What OS? What exactly is the "thing" the C++ method returns? How do you use it later?
There might be a way to create the right DBI object wrapping the connection opened elsewhere, but if there is it will be driver specific.
Jenda
Enoch was right!
Enjoy the last years of Rome.
| [reply] |
|
|
Apologies: Oracle 10, on Solaris 5.10, using ProC/C++ and Sun C++ 5.9. Perl is 5.8. It's a typical Oracle Connection instance which is returned.
| [reply] |
|
|
| [reply] |
|
|
Re: DB -> C++ -> XS/Swig -> DBI -> Perl
by bulk88 (Priest) on Jan 30, 2014 at 00:34 UTC
|
Distributing object code is not security. Use a disassembler, or debugger with asm level breakpoints. Put a breakpoint on the start of the asm code of the db connection function call. Look at register esp/rsp, and the C prototype of the db connect function. Look at the C stack as 4/8byte int arrays. On entry to the C function, esp/rsp will be -4/-8 from return address or on the return address, Work your way numerically upwards from the pointer in reg esp. One of those will a string pointer with the db username and password. | [reply] |
|
|
Possibly another way to get username and password: If database and "secret" C++ code run or can run on different machines, connect both machines with a hub (or a managed switch with a "monitor" port), connect a third machine running wireshark, trace packages send from the client to the database. My guess is that the database does not encrypt communication, at least not by default. Probably, wireshark knows the database protocol. In the best case, username and password are send in plain text over the wire.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] |
|
|
That does not answer the question. We all know what you describe can be done.
| [reply] |
|
|
Hum the thing is getting old but by the way I've to need the right to access it:
cpan> install DBD::Oracle
CPAN::SQLite not installed, trying to work without
Reading 'C:\STRAWB~1\cpan\Metadata'
Database was generated on Sun, 01 Jan 2023 22:54:07 GMT
Running install for module 'DBD::Oracle'
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/Z/ZA/ZARQUON/DBD-Oracle-1.83
+.tar.gz
LWP failed with code[501] message[Can't load 'C:\xampp\perl\vendor\lib
+/auto/Net/SSLeay/SSLeay.xs.dll' for module Net::SSLeay: load_file:Le
+module spÚcifiÚ est introuvable (LWP::Protocol::https not installed)]
Warning: no success downloading 'C:\STRAWB~1\cpan\sources\authors\id\Z
+\ZA\ZARQUON\DBD-Oracle-1.83.tar.gz.tmp4192'. Giving up on it.
Fetching with LWP:
http://www.cpan.org/authors/id/Z/ZA/ZARQUON/DBD-Oracle-1.83.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/Z/ZA/ZARQUON/CHECKSUMS
Checksum for C:\STRAWB~1\cpan\sources\authors\id\Z\ZA\ZARQUON\DBD-Orac
+le-1.83.tar.gz ok
Scanning cache C:\STRAWB~1\cpan\build for sizes
......................................................................
+......DONE
Configuring Z/ZA/ZARQUON/DBD-Oracle-1.83.tar.gz with Makefile.PL
Can't locate DBI.pm in @INC (you may need to install the DBI module) (
+@INC contains: C:/xampp/perl/site/lib C:/xampp/perl/vendor/lib C:/xam
+pp/perl/lib .) at Makefile.PL line 20.
BEGIN failed--compilation aborted at Makefile.PL line 20.
Warning: No success on command[C:\xampp\perl\bin\perl.exe Makefile.PL]
ZARQUON/DBD-Oracle-1.83.tar.gz
C:\xampp\perl\bin\perl.exe Makefile.PL -- NOT OK
Stopping: 'install' failed for 'DBD::Oracle'.
Failed during this command:
ZARQUON/DBD-Oracle-1.83.tar.gz : writemakefile NO 'C:\x
+ampp\perl\bin\perl.exe Makefile.PL' returned status 512
cpan>
| [reply] [d/l] |
|
|
|
|