Jump to content
Sign in to follow this  
Havoc

Make a random variables

Recommended Posts

Havoc

Hello,

I'm trying to make strings random in url. For example:

Url is: http://google.com/?index.php?$variable1=15&variable2=20&variable=30and go on.

I need to make them random like some times $variable1=15&variable2=20&variable=30, sometimes $variable1=15, somtimes $variable1=15&variable2=20

Is there any ideas? I have tried with random() but is not that accurate what I needed. Probably is with array or something else.

Thank you.

Edited by Havoc

Share this post


Link to post
Share on other sites
jguinch

Something like this ?

$sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable=30"
$sUrlVar = "([&?][^=]+=[^&]*)"

$sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "")
ConsoleWrite($sShortURL)
Edited by jguinch

Share this post


Link to post
Share on other sites
Havoc

 

Something like this ?

$sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable=30"
$sUrlVar = "([&?][^=]+=[^&]*)"

$sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "")
ConsoleWrite($sShortURL)

Yes that's right! I have got one problem, I need to use 6 variables then script will work what I needed. I have 80 variables. I need to get 6 like 1.

Example:

http://google.com/index.php?$variable1=15&variable2=20&variable3=30$variable4=15&variable5=20&variable6=30

$variable1=15&variable2=20&variable3=30$variable4=15&variable5=20&variable6=30 - should get like 1.

Basiclly 6 counts as 1.

Edited by Havoc

Share this post


Link to post
Share on other sites
Havoc

Try with $sUrlVar = "(([&?][^=]+=[^&]*){6})"

Hmm. Nothing changes.

Share this post


Link to post
Share on other sites
Havoc

$sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable3=30$variable4=15&variable5=20&variable6=30$variable7=15&variable8=20&variable9=30$variable10=15&variable11=20&variable12=30"
$sUrlVar = "(([&?][^=]+=[^&]*){6})"
$sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "")
ConsoleWrite($sShortURL)

Share this post


Link to post
Share on other sites
jguinch

You url contains some & and some $ : is it normal ?

If I replace all $ by &, it seems to work :

$sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable3=30&variable4=15&variable5=20&variable6=30&variable7=15&variable8=20&variable9=30&variable10=15&variable11=20&variable12=30"
$sUrlVar = "(([&?][^=]+=[^&]*){6})"

For $i = 1 To 100
    $sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "")
    ConsoleWrite($sShortURL & @CRLF)
Next

Share this post


Link to post
Share on other sites
Havoc

 

You url contains some & and some $ : is it normal ?

If I replace all $ by &, it seems to work :

$sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable3=30&variable4=15&variable5=20&variable6=30&variable7=15&variable8=20&variable9=30&variable10=15&variable11=20&variable12=30"
$sUrlVar = "(([&?][^=]+=[^&]*){6})"

For $i = 1 To 100
    $sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "")
    ConsoleWrite($sShortURL & @CRLF)
Next

Thank you a lot!

Share this post


Link to post
Share on other sites
Havoc

I have got one more question. How to make it now that those variables I can control randomly?
Basiclly like I said 6 as 1. But now I need this I can do random them sometimes 6*5,6*9,6*20 and so on.

If I make random(1,5) I should get between 1 and 5. So script make no sense for me tried.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

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.