Skip to content

Commit

Permalink
added --whatis command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
pk-fr committed Jan 23, 2016
1 parent 6263bbf commit 062583b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ Recursivly removes target_directory/yakpro-po
--scramble-length length ( min=2; max = 16 for scramble_mode=identifier,
max = 32 for scramble_mode = hexa or numeric)

--whatis scrambled_name retrieves original symbol from obfuscation context.
(usefull for debugging your code when you give away
obfuscated code, and keep the same obfuscation context).
Tip: do not include the $ symbol, or use \$ because
$ has special meaning in shell.

-h or
--help displays help.

Expand Down
5 changes: 5 additions & 0 deletions include/classes/scrambler.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ public function scramble($s)
return $this->case_sensitive ? $this->t_scramble[$r] : $this->case_shuffle($this->t_scramble[$r]);
}

public function unscramble($s)
{
return isset($this->t_rscramble[$s]) ? $this->t_rscramble[$s] : '';
}

public function generate_label_name($prefix = "!label")
{
return $prefix.($this->label_counter++);
Expand Down
8 changes: 8 additions & 0 deletions include/retrieve_config_and_arguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
array_splice($t_args,$pos,1); // remove the arg and reorder
} else $force_conf_silent = false;;

$pos = array_search('--whatis',$t_args);
if ( isset($pos) && ($pos!==false) && isset($t_args[$pos+1]) )
{
$whatis = $t_args[$pos+1];
array_splice($t_args,$pos,2); // remove the 2 args and reorder
$force_conf_silent = true;
} else $whatis = '';

$pos = array_search('--debug',$t_args);
if (isset($pos) && ($pos!==false) )
{
Expand Down
6 changes: 6 additions & 0 deletions locale/fr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ Supprime récursivement le répertoire répertoire_cible/yakpro-po
--scramble-length longueur ( min=2; max = 16 pour scramble_mode=identifier,
max = 32 pour scramble_mode = hexa ou numeric)

--whatis scrambled_name retrouve le nom d'origine à partir du contexte d'obfuscation.
(utile pour debugger votre code lorsque vous délivrez du code
obfusqué, et que vous avez gardé le même contexte d'obfuscation).
Conseil : n'utilisez pas le symbole $, ou faites le précéder du
caractère \ car $ est interprété par le shell.

-h ou
--help afficher l'aide.

Expand Down
21 changes: 21 additions & 0 deletions yakpro-po.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@
{
$t_scrambler[$scramble_what] = new Scrambler($scramble_what, $conf, ($process_mode=='directory') ? $target_directory : null);
}
if ($whatis!=='')
{
if ($whatis{0} == '$') $whatis = substr($whatis,1);
foreach(array('variable','function','method','property','class','class_constant','constant','label') as $scramble_what)
{
if ( ( $s = $t_scrambler[$scramble_what]-> unscramble($whatis)) !== '')
{
switch($scramble_what)
{
case 'variable':
case 'property':
$prefix = '$';
break;
default:
$prefix = '';
}
echo "$scramble_what: {$prefix}{$s}".PHP_EOL;
}
}
exit;
}

$traverser->addVisitor(new MyNodeVisitor);

Expand Down

0 comments on commit 062583b

Please sign in to comment.