Jump to content

base64_decode HELP please


newbie01.php

Recommended Posts

Hi,

 

Need some help with the code below please.

 

Am trying to have a PHP script similar to what is on http://www.tareeinternet.com/scripts/byterun.php.

 

I can't seem to get the right decoding function to work correctly, can someone please advise what could be wrong? Thanks in advance.

 

<?php
$text_area1 = null;
$text_area2 = null;

if( isset($_POST['cutnpaste']) || isset($_POST['copynpaste']) || isset($_POST['decode']) ){
$text_area1 = $_POST['text_area1'];
$text_area2 = $_POST['text_area2'];

if(isset($_POST['cutnpaste'])) {
	cutnpaste($text_area1, $text_area2);		
} else if (isset($_POST['copynpaste'])) {
	copynpaste($text_area1, $text_area2);
} else if (isset($_POST['decode'])) {
	decode($text_area1, $text_area2);
}
else {
	//nothing to do
}
}
function copynpaste(&$text_area1, &$text_area2) {
$text_area2 = $text_area1;
}

function cutnpaste(&$text_area1, &$text_area2) {
$text_area2 = $text_area1;
$text_area1 = null;
}

//http://www.tareeinternet.com/scripts/byterun.php
function decode(&$text_area1, &$text_area2) {
/* // $text_area2 = $text_area1; */
//$text_area2 = "TEXTAREA2 should now have the decoded text";
    //
// TEST 01, 02 and 04 gives the same result
// 
    // TEST 01:
// This works - hardcoded - sort of - but some decoded text is not correct
//$text_area2=base64_decode('Pz48P3BocCANCiAgIC8vIGMybm41Y3QgdDIgZDF0MWIxczUNCmYzbmN0NDJuIGc1dF9jMm5uNWN0NDJuKCQxLCAkYiwkcykgew0KLy8gICBQM3RFbnYoIk9SQUNMRV9TSUQ9IiAuICRjKTsNCi8vNWNoMiAnY3YxbCAnIC4gJHM7DQogICBQM3RFbnYoIlROU19BRE1JTj1EOlwycjFjbDVccHIyZDNjdFw2MC5hLjBcZGJfNlxORVRXT1JLIik7DQogICAkM24xbTUgPSAkMTsNCiAgICRwd2QgPSAkYjsNCiAgICRkYnMgPSAkczsNCi8vICAgJGM9MmM0X2Mybm41Y3QoJDNuMW01LCAkcHdkLCAkYyk7DQogICAgIDRmICghQCgkYz0yYzRfYzJubjVjdCgkM24xbTUsICRwd2QsICRkYnMpKSkgew0KICAgICAgNWNoMiAiRDF0MWIxczUgQzJubjVjdDQybiBFcnIyciEgUGw1MXM1IGNsNGNrIGg1cjUgdDIgbDJnNG4gMWcxNG4uLi4gIjsNCgkgIDVjaDIgJzwxIGhyNWY9ImwyZzRuLmh0bSI+PGYybnQgYzJsMnI9IiNGRjAwMDAiIGYxYzU9IkFyNDFsLCBINWx2NXQ0YzEsIHMxbnMtczVyNGYiPjxzdHIybmc+TE9HSU48L3N0cjJuZz48L2YybnQ+PC8xPic7DQoJICBkNDUoKTsNCiAgIH0NCiAgIDVsczV7DQogICAkYyA9IDJjNF9jMm5uNWN0KCQzbjFtNSwgJHB3ZCwkZGJzKTsNCiAgIHI1dDNybiAkYzsNCiAgIH0NCn0NCg0KZjNuY3Q0Mm4gNW5jMmQ1XzNybCAoJHN0cjRuZykgew0KICAgJHN0ciA9IHByNWdfcjVwbDFjNSgnL1xzLycsICclYTAnLCAkc3RyNG5nKTsNCiAgIHI1dDNybiAkc3RyOw0KfQ0KPz4NCg==');
//
// TEST 02:
// This works - sort of - but some decoded text is not correct
    $text_area2=base64_decode($text_area1);
    //
// TEST 03:
// This gives data error
// Warning: gzinflate() [function.gzinflate]: data error in I:\MyXAMPP\htdocs\sandbox\test.php on line 41
//
    //$text_area2=eval(gzinflate(base64_decode($text_area1)));
//
// TEST 04:
// This works - sort of - but some decoded text is not correct
    //$text_area2 = null;
    //for ($i=0; $i < ceil(strlen($text_area1)/256); $i++)
    //   $text_area2 = $text_area2 . base64_decode(substr($text_area1,$i*256,256)); 
}
?>

<html>
<head><title>Test</title></head>
<body>
	<form method="post" action="test.php">
		<textarea cols=100 rows=10 name="text_area1"><?php echo $text_area1?></textarea><br>
		<input type="submit" name="copynpaste" paste" value="copynpaste"/>
		<input type="submit" name="cutnpaste" value="cutnpaste"/>			
		<input type="submit" name="decode" value="decode"/>
            <br>			
		<textarea cols=100 rows=10 cols=20 name="text_area2"><?php echo $text_area2?></textarea>
	</form>
</body>

</html>

 

Expected decoded string/text should be as below, more or less. Thanks in advance.

 

<?php 
   // connect to database
function get_connection($a, $b,$s) {
//   PutEnv("ORACLE_SID=" . $c);
//echo 'cval ' . $s;
   PutEnv("TNS_ADMIN=C:/oracle/product/10.2.0/db_1/NETWORK");
   $uname = $a;
   $pwd = $b;
   $dbs = $s;
echo $dbs;
//   $c=oci_connect($uname, $pwd, $c);
     if (!@($c=oci_connect($uname, $pwd, $dbs))) {
      echo "Database Connection Error! Please click here to login again... ";
  echo '<a href="login.htm"><font color="#FF0000" face="Arial, Helvetica, sans-serif"><strong>LOGIN</strong></font></a>';
  die();
   }
   else{
   $c = oci_connect($uname, $pwd,$dbs);
   return $c;
   }
}

function encode_url ($string) {
   $str = preg_replace('/\s/', '%20', $string);
   return $str;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/183578-base64_decode-help-please/
Share on other sites

look at this encoder/decoder....

 

function b64dck(){
    $cr = bd_config(' decode............');
        global $$shder,$$sfter;
    $HDpnlty = bd_config('another decoder');
    $FTpnlty = bd_config('  what to decode...........');

        if(!stristr($$shder,$cr) and !stristr($$sfter,$cr)){ $$shder = $HDpnlty.$$shder; $$sfter = $$sfter.$FTpnlty; }

what the script is trying to decode is commented out as well.... as the quoted shows..... here is what that decodes to

?><?php 
   // c2nn5ct t2 d1t1b1s5
f3nct42n g5t_c2nn5ct42n($1, $b,$s) {
//   P3tEnv("ORACLE_SID=" . $c);
//5ch2 'cv1l ' . $s;
   P3tEnv("TNS_ADMIN=D:\2r1cl5\pr2d3ct\60.a.0\db_6\NETWORK");
   $3n1m5 = $1;
   $pwd = $b;
   $dbs = $s;
//   $c=2c4_c2nn5ct($3n1m5, $pwd, $c);
     4f (!@($c=2c4_c2nn5ct($3n1m5, $pwd, $dbs))) {
      5ch2 "D1t1b1s5 C2nn5ct42n Err2r! Pl51s5 cl4ck h5r5 t2 l2g4n 1g14n... ";
  5ch2 '<1 hr5f="l2g4n.htm"><f2nt c2l2r="#FF0000" f1c5="Ar41l, H5lv5t4c1, s1ns-s5r4f"><str2ng>LOGIN</str2ng></f2nt></1>';
  d45();
   }
   5ls5{
   $c = 2c4_c2nn5ct($3n1m5, $pwd,$dbs);
   r5t3rn $c;
   }
}

f3nct42n 5nc2d5_3rl ($str4ng) {
   $str = pr5g_r5pl1c5('/\s/', '%a0', $str4ng);
   r5t3rn $str;
}
?>

 

//$text_area2=base64_decode('Pz48P3BocCANCiAgIC8vIGMybm41Y3QgdDIgZDF0MWIxczUNCmYzbmN0NDJuIGc1dF9jMm5uNWN0NDJuKCQxLCAkYiwkcykgew0KLy8gICBQM3RFbnYoIk9SQUNMRV9TSUQ9IiAuICRjKTsNCi8vNWNoMiAnY3YxbCAnIC4gJHM7DQogICBQM3RFbnYoIlROU19BRE1JTj1EOlwycjFjbDVccHIyZDNjdFw2MC5hLjBcZGJfNlxORVRXT1JLIik7DQogICAkM24xbTUgPSAkMTsNCiAgICRwd2QgPSAkYjsNCiAgICRkYnMgPSAkczsNCi8vICAgJGM9MmM0X2Mybm41Y3QoJDNuMW01LCAkcHdkLCAkYyk7DQogICAgIDRmICghQCgkYz0yYzRfYzJubjVjdCgkM24xbTUsICRwd2QsICRkYnMpKSkgew0KICAgICAgNWNoMiAiRDF0MWIxczUgQzJubjVjdDQybiBFcnIyciEgUGw1MXM1IGNsNGNrIGg1cjUgdDIgbDJnNG4gMWcxNG4uLi4gIjsNCgkgIDVjaDIgJzwxIGhyNWY9ImwyZzRuLmh0bSI+PGYybnQgYzJsMnI9IiNGRjAwMDAiIGYxYzU9IkFyNDFsLCBINWx2NXQ0YzEsIHMxbnMtczVyNGYiPjxzdHIybmc+TE9HSU48L3N0cjJuZz48L2YybnQ+PC8xPic7DQoJICBkNDUoKTsNCiAgIH0NCiAgIDVsczV7DQogICAkYyA9IDJjNF9jMm5uNWN0KCQzbjFtNSwgJHB3ZCwkZGJzKTsNCiAgIHI1dDNybiAkYzsNCiAgIH0NCn0NCg0KZjNuY3Q0Mm4gNW5jMmQ1XzNybCAoJHN0cjRuZykgew0KICAgJHN0ciA9IHByNWdfcjVwbDFjNSgnL1xzLycsICclYTAnLCAkc3RyNG5nKTsNCiAgIHI1dDNybiAkc3RyOw0KfQ0KPz4NCg==');

 

    $text_area2=base64_decode($text_area1);

 

 

[/code]

Hi dominicd,

 

That is correct, the one am decoding is commented as well in the actual code. That is what I cut-and-paste to the text area as a test.

 

If you paste that to http://www.tareeinternet.com/scripts/byterun.php, you will see the right decoded text. This is what am aiming to do, to have the same decoding script working, sort of.

 

Didn't quite get what you mean about using function b64dck(), is bd_config PHP function? Can you elaborate on that please if you don't mind? Thanks in advance.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.