Archives de catégorie : code

Futilities…

Netgear DM111P backdoor?

After reading @elvanderb‘s tweet about a backdoor in his Linksys WAG200G, I checked my Netgear DM111P DSL modem (running firmware V2.00.27_WW) and found that TCP/32764 was opened and responding in a similar way. The admin’s HTTP password is also exposed … Continuer la lecture

Publié dans code, network | Laisser un commentaire

Problème de connexion à eurosportplayer.fr avec Safari ?

Si vous n’arrivez pas à vous connecter au player Eurosport avec Safari sur Mac OS X (vous retournez sans cesse sur la page de login), et que vous avez un nom/prénom avec un (ou des) accent(s), le problème peut venir … Continuer la lecture

Publié dans code | Laisser un commentaire

Rollout your own DomainKeys-like signature verification in PHP

Reading documentation on DKIM I found it usefull to be able to distribute public keys through DNS to allow recipient to check signed content against it. So, here is a couple of DomainKeysSigner and DomainKeysVerifier PHP classes that implement the sign … Continuer la lecture

Publié dans code, system | Laisser un commentaire

Enable Xdebug profiler in PHP CLI

When running with Apache PHP SAPI, the Xdebug profiler can be triggered by appending the « XDEBUG_PROFILER=1 »  to the GET or POST request. But how do you trigger the profiler with the CLI SAPI?

Publié dans code | Laisser un commentaire

Log PHP memory consumption on each Apache requests

Edit your Apache conf and and %{mod_php_memory_usage}n to the LogFormat directive to log the PHP memory consumption in bytes : LogFormat « %h %l %u %t \ »%r\ » %>s %b » %{mod_php_memory_usage}n Save and reload Apache.

Publié dans code, system | Laisser un commentaire

Doing TCP/HTTP with Bash

Bash have the ability to do I/O on TCP sockets through the special file « /dev/tcp/<host>/<port> ». Here is a simple setup that demonstrate this capability by implementing a simple HTTP client.

Publié dans code | Laisser un commentaire

Setting Postgresql work_mem from PHP

I discovered that one can set the work_mem from PHP after connecting to the database and before issuing heavy requests : <?php $conn = pg_connect(« service=test »); // Set work_mem to 128MB $res = pg_query(sprintf(« SET work_mem = ‘%s' », pg_escape_string(‘128MB’))); // Run your query … Continuer la lecture

Publié dans code, system | Laisser un commentaire

Postgresql table and index size

Here is a Postgresql requests which will allows you to view the size of your tables with their idx_scan and seq_scan counts. SELECT s.schemaname, s.relname, c.oid, c.relfilenode, s.seq_scan,s.idx_scan, c.relpages AS pages FROM pg_stat_all_tables AS s, pg_class AS c WHERE s.relname … Continuer la lecture

Publié dans code, system | Laisser un commentaire

fuser in PHP

fuser is a handy command when you need to check if a file is currently opened by processes. Here is an implementation in PHP which will work on Linux by scanning the `/proc/<pids>/fd‘ sub-directories.

Publié dans code | Laisser un commentaire

Signing large files with PHP openssl extension

The openssl extension for PHP provides the openssl_sign() function to sign data. The drawback of this function is that the data is fed with a single variable holding the entire data to be signed. This implies that all your data … Continuer la lecture

Publié dans code | 4 commentaires