Created
November 15, 2021 02:43
-
-
Save Sarverott/5c1a1ea571999df0383c9aec12b5b0b8 to your computer and use it in GitHub Desktop.
PHP script to including for randomization of html ids and classes, css selectors, js variables or else. Usefull against automated man-in-the-browser activities like bruteforce attacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
** ###### Names Of Odin v1.0.0 ###### (previously published as repository) | |
** by Sett Sarverott @ 2018 | |
** MIT Licence | |
*/ | |
class namesGenotype{ | |
private $nameslength; | |
private $nameseed=[]; | |
public $namesspace=array(); | |
public function __construct($len=10){ | |
$this->nameslength=$len; | |
for($i=0;$i<$this->nameslength;$i++){ | |
if($i==0){ | |
$this->nameseed[]=rand(0,25); | |
}else{ | |
$this->nameseed[]=rand(0,25); | |
} | |
} | |
} | |
private function letter_alg($notfirst, $x, $seed){ | |
$var=0; | |
if($x%2==0){ | |
$var=$seed-round($x/2); | |
}else{ | |
$var=$seed+$x-round(($x-1)/2); | |
} | |
if($var<0){ | |
$var+=26; | |
}elseif($var>=26){ | |
$var%=26; | |
} | |
if($var<26&&$var>=0){ | |
return chr($var+97); | |
} | |
} | |
public function get_name($index){ | |
if(!isset($this->namesspace[$index])){ | |
$this->namesspace[$index]=""; | |
for($i=0;$i<$this->nameslength;$i++){ | |
$this->namesspace[$index]=$this->letter_alg($i,round($index/(pow(26, $i)))%26,$this->nameseed[$i]).$this->namesspace[$index]; | |
} | |
} | |
return $this->namesspace[$index]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
example of class names mutation, used in css, js and html | |
--> | |
<?php | |
define("TEST_LENGTH_NAMES", 5); | |
include "names-of-odin.php"; | |
$selektory=new namesGenotype(TEST_LENGTH_NAMES); | |
?> | |
<style> | |
.<?php echo $selektory->get_name(0); ?>{ | |
color:#f0f; | |
} | |
.<?php echo $selektory->get_name(1); ?>{ | |
color:#00f; | |
} | |
.<?php echo $selektory->get_name(2); ?>{ | |
background:#faa; | |
} | |
.<?php echo $selektory->get_name(999999); ?>{ | |
text-decoration:underline overline; | |
font-size:23px; | |
} | |
#<?php echo $selektory->get_name(880); ?>{ | |
font-family:arial; | |
} | |
.<?php echo $selektory->get_name(696969); ?>{ | |
clear:both; | |
} | |
#<?php echo $selektory->get_name(1234567); ?>, #<?php echo $selektory->get_name(7654321); ?>{ | |
float:left; | |
} | |
#<?php echo $selektory->get_name(7654321); ?>{ | |
width: 59%; | |
} | |
#<?php echo $selektory->get_name(1234567); ?>{ | |
width: 40%; | |
} | |
</style> | |
<script> | |
var i=0; | |
var a=['#f00','#0f0','#00f']; | |
setInterval(function(){ | |
i++; | |
console.log(":::START::: color changing for class: '<?php echo $selektory->get_name(999999); ?>' at "+(i*0.5)+((i%2==0)?".0":"")+"s - changing color into: "+a[i%3]); | |
for(var j=0;j<document.getElementsByClassName('<?php echo $selektory->get_name(999999); ?>').length;j++){ | |
document.getElementsByClassName('<?php echo $selektory->get_name(999999); ?>')[j].style.color=a[i%3]; | |
console.log("element with class nr."+(1+j)); | |
} | |
console.log(":::END:::"); | |
console.log("- - - - -"); | |
}, 500); | |
</script> | |
<h1 class="<?php echo $selektory->get_name(0); ?>"> | |
Title with class named "<mark><?php echo $selektory->get_name(0); ?></mark>" | |
</h1> | |
<p class="<?php echo $selektory->get_name(1)." ".$selektory->get_name(2); ?>" id="<?php echo $selektory->get_name(880); ?>"> | |
paragrah with classes named " | |
<mark> | |
<?php echo $selektory->get_name(1); ?> | |
</mark> | |
" and " | |
<mark> | |
<?php echo $selektory->get_name(2); ?> | |
</mark> | |
" and with id " | |
<mark> | |
<?php echo $selektory->get_name(880); ?> | |
</mark>" | |
</p> | |
<br> | |
<br> | |
<div> | |
current names length: | |
<span class="<?php echo $selektory->get_name(999999); ?>"> | |
<?php echo TEST_LENGTH_NAMES; ?> | |
</span> | |
<br> | |
<br> | |
maximum number of names for | |
<?php echo TEST_LENGTH_NAMES; ?> | |
char length: | |
<span class="<?php echo $selektory->get_name(999999); ?>"> | |
<?php echo pow(26, TEST_LENGTH_NAMES); ?> | |
</span> | |
</div> | |
<br> | |
<br> | |
<div> | |
<div id="<?php echo $selektory->get_name(7654321); ?>"> | |
<h1>List of existing in memory randomised names</h1> | |
<pre><?php | |
//for($i=0;$i<100;$i++) $selektory->get_name($i); | |
var_dump($selektory->namesspace); | |
?></pre> | |
</div> | |
<div id="<?php echo $selektory->get_name(1234567); ?>"> | |
<h3>List after using 10 random names</h3> | |
<pre><?php | |
for($i=0;$i<10;$i++) $selektory->get_name(round(rand()^2/32768)); | |
var_dump($selektory->namesspace); | |
?></pre> | |
</div> | |
<div class="<?php echo $selektory->get_name(696969); ?>"></div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MIT License | |
Copyright (c) 2018 Sett Sarverott | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment