RCG needs help with possible poison characters (getting clos
Moderator: DosItHelp
Re: RCG needs help with possible poison characters (getting
So you are telling me that you are building strings of characters and you aren't going to use them?
I don't know if you are intentionally misunderstanding my question...
I don't know if you are intentionally misunderstanding my question...
-
- Posts: 76
- Joined: 21 Dec 2011 14:21
Re: RCG needs help with possible poison characters (getting
foxidrive wrote:So you are telling me that you are building strings of characters and you aren't going to use them?
I don't know if you are intentionally misunderstanding my question...
its not that im not going to use them, its just that the batch file only has to emit the char's to the screen. i cut and paste the result and use it as a random passcode for programs that require it (like irfanview's SaveAsPDF, you have to put in a passcode during the Save or it makes a random one to use)
does that make sense?
Re: RCG needs help with possible poison characters (getting
timbertuck wrote:well, in doing some range testing, i found out that the simplified program does not emit the doublequotes " in the selection set. i trimmed it down a little bit more so it is more concise. i did the same for your program but yours does not do the doublequote " either. so i will post both codes. so my question is how to get the doublequote to emit properly.
yourRand.basCode: Select all
@echo off &setlocal enableextensions enabledelayedexpansion
:main ()
set "$charSet=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
set "$charSet"
for /l %%? in (1, 1, 20) do (
set "$string=" &for /l %%? in (1, 1, 64) do (
set /a $random = !random! %% 33 &for %%? in (!$random!) do set "$char=!$charSet:~%%?,1!"
set "$string=!$string!!$char!"
)
if %%? LSS 10 set "$string[%%?] = !$string!"
if %%? GEQ 10 set "$string[%%?] = !$string!"
set "$string[%%?]"
)
pause &endlocal &exit /b
timbertuck wrote:and shouldn't the random 33 be actually 34 (as there are 33 special char's including the space) oops never mind my error
Code: Select all
@echo off &setlocal enableextensions enabledelayedexpansion
::
:main ()
:: (
set "$charSet=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
set "$charSet"
::
for /l %%? in (
1, 1, 4
) do (
set "$string=" &for /l %%? in (
1, 1, 64
) do (
set /a $random = !random! %% 34 &for %%? in (
!$random!
) do set "$char=!$charSet:~%%?,1!"
::
set "$string=!$string!!$char!"
)
::
set "$string[%%?]=!$string!"
set "$string[%%?]"
)
:: )
pause &endlocal &exit /b
Code: Select all
$charSet=^~`@#$&:;_/.,-+=\|][{}'?()@*<> !%"
$string[1]="'}=+~~|>>* :^@|+$''!:{(+? @_{[[-$-?/<^<~_[>>==(^{^"|]@>^>. >,?]
$string[2]==!;][=-#;?-( ,`*/{(,.:@_'$%{'\#%$(]+\,">\?*[?*_,~#_<`-[]^~'/@/_>
$string[3]=]"<={-]!;!#]:.:;% + /#;"@`[;=\{|`%^+&,@$/`<#.~%(@?}'{=}&^_;:$:/@
$string[4]=&&)$~=_:!_{/|_","):^]!~>{%:'% _@$% {+ @]>^%~/( <@?({^`'"!?}["^,>
Druk op een toets om door te gaan. . .
In that case, I'd prefer writing to a file and copy from notepad.timbertuck wrote:i cut and paste the result and use it as a random passcode for programs that require it (like irfanview's SaveAsPDF, you have to put in a passcode during the Save or it makes a random one to use)
Code: Select all
>file.TMP (
echo.result
)
start "" /wait notepad.EXE "file.TMP"
del file.TMP
-
- Posts: 76
- Joined: 21 Dec 2011 14:21
Re: RCG needs help with possible poison characters (getting
how can i get this to work?
code working
code not working
the value "10" can go up as high as 999.
thanks for your help.
code working
Code: Select all
if /i "%1"=="/s" (
endlocal
set "$string[10]=%lastval[10]%"
set "$string[9]=%lastval[9]%"
set "$string[8]=%lastval[8]%"
set "$string[7]=%lastval[7]%"
set "$string[6]=%lastval[6]%"
set "$string[5]=%lastval[5]%"
set "$string[4]=%lastval[4]%"
set "$string[3]=%lastval[3]%"
set "$string[2]=%lastval[2]%"
set "$string[1]=%lastval[1]%"
)
code not working
Code: Select all
if /i "%1"=="/s" (
endlocal
for /l %%a in (10,-1,1) do (
set "$string[%%a]=%lastval[%%a]%"
)
)
the value "10" can go up as high as 999.
thanks for your help.
-
- Posts: 76
- Joined: 21 Dec 2011 14:21
Re: RCG needs help with possible poison characters (getting
Ed Dyreen wrote:In that case, I'd prefer writing to a file and copy from notepad.Or even better copy to clipboard directly from batch.Code: Select all
>file.TMP (
echo.result
)
start "" /wait notepad.EXE "file.TMP"
del file.TMP
i was trying to keep this lightweight without resorting to using files
so i have this running (with one exception, asked in previous post) and it works as expected using all keyboard characters.
Code: Select all
@echo off
set $string[1]=
set $string[2]=
set $string[3]=
set $string[4]=
set $string[5]=
set $string[6]=
set $string[7]=
set $string[8]=
set $string[9]=
set $string[10]=
setlocal enableextensions enabledelayedexpansion
if "%1"=="" goto :askque4
if /i "%1"=="/h" goto :help
if "%1"=="/?" goto :help
goto :askque4
:help
echo %0 will create a block of random code based on your input.
echo.
echo The program will ask for character set, loop count and byte size.
echo.
echo The max for loop count is 999
echo The max for byte size is 256
echo.
echo Thus the max block size is ~255K, you will need to extend the DOS console
echo session so that the screen buffer width is 256 or greater, that will fit
echo the entire block on a page. You will need to be able to scroll to capture
echo the entire block. Remember to press Enter to complete the copy.
echo.
echo The character set can be one of the following: Unique Key's
echo ________ ___________________________________ ____________
echo.
echo Alpha - Upper and Lower Case A-Z, a-z ^(52^)
echo Extended - Alpha + Number + Special Characters ^(95^)
echo Hex - Hexadecimal A-Z,0-9 ^(16^)
echo Number - Numbers 0-9 ^(10^)
echo AlphaNum - AlphaNumeric A-Z, a-z, 0-9 ^(62^)
echo Special - All special characters ^(33^)
echo.
echo This program will produce ^("to the best of its known abilites"^) completely
echo random code.
echo.
echo The default charcter set is Hex, Loop Count is 32 and Byte Size is 16.
echo This is a 512 character block of random code to use as you deem fit.
echo Max possibilites 16 ^^^^ 32 = 1.208925819614629e+24.
echo.
pause > nul | echo Press any key to see More...
echo.
echo ^Tip: You can use the Edit-^>Mark command of the console to mark a block of text,
echo hit enter to save selected text. Then you can paste into another document or
echo program.
echo.
echo Tip: Set the properties of the CMD.EXE to Quick Edit mode. Then mark text with
echo Left click and Drag, Right click to copy selected text. Paste to document or
echo program.
echo.
echo Tip: To save the result(s) to the environment table, use the /s switch. Type
echo "SET $string" to view the ouptut of %0. Note: Running a subsuquent %0
echo without the /s switch will clear the previous output to the environment table.
echo.
echo The Author ^(and other Distributers^) of this software will not be held
echo responsible for any damages caused by said software. The is no warranty,
echo implied or otherwise. This is to be used for your education of Random Code
echo Generator's.
goto :eof
set "n=0123456789"
set "h=ABCDEF0123456789"
set "a=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
set "an=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
set "e=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
set "s=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
:askque4
:: find out which character set to use
echo CharSet(Possibilities) Expanded
echo ====================== ====================================
echo Alpha^(52^) A-Z, a-z
echo AlphaNumeric^(62^) A-Z, a-z, 0-9
echo Extended^(95^) A-Z, a-z, 0-9, All keyboard symbols
echo Hex^(16^) A-F, 0-9
echo Numbers^(10^) 0-9
echo Special^(33^) All keyboard symbols
echo.
set /p CharSet=Choose Character Set [A^/AN^/E^/H^/N^/S] ^<H^>
echo.
if "%CharSet%"=="" set CharSet=H
if /i not "%CharSet%"=="A" if /i not "%CharSet%"=="E" if /i not "%CharSet%"=="H" if /i not "%CharSet%"=="N" if /i not "%CharSet%"=="AN" if /i not "%CharSet%"=="S" goto :askque4
:askque1
:: how many time to repeat random request
set /p MaxLoop=How many times to repeat selection? [1-999] ^<20^>
if "%MaxLoop%"=="" set MaxLoop=20
if %MaxLoop% GTR 0 if %MaxLoop% LSS 1000 goto :askque2
echo.
echo %MaxLoop% not in the expected range [1-99]
echo.
goto askque1
:askque2
:: get the amount of characters to display per string
set /p byteCount=How many characters do you want to display per line? [1-256] ^<16^>
if "%byteCount%"=="" set byteCount=16
if %byteCount% GTR 0 if %byteCount% LSS 257 goto :main
echo.
echo %byteCount% not in the expected range [1-256]
echo.
goto askque2
:main ()
echo.
if /i "%CharSet%"=="A" (set charMax=52) & set "$CharSet=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
if /i "%CharSet%"=="H" (set charMax=16) & set "$CharSet=0123456789ABCDEF"
if /i "%CharSet%"=="E" (set charMax=95) & set "$CharSet=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
if /i "%CharSet%"=="N" (set charMax=10) & set "$CharSet=0123456789"
if /i "%CharSet%"=="S" (set charMax=33) & set "$CharSet=^^~`@#$&:;_/.,-+=\|][{}'?()@*<> ^!%%"^"
if /i "%CharSet%"=="AN" (set charMax=62) & set "$CharSet=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
echo "$charset = %$charSet%"
for /l %%? in (
1, 1, %maxloop%
) do (
set "$string=" &for /l %%? in (
1, 1, %byteCount%
) do (
set /a $random = !random! %% %charMax% &for %%? in (
!$random!
) do set "$char=!$charSet:~%%?,1!"
set "$string=!$string!!$char!"
)
if %%? LSS 1000 if %%? GEQ 100 set "$string[%%?]= !$string!"
if %%? LSS 100 if %%? GEQ 10 set "$string[%%?] = !$string!"
if %%? LSS 10 set "$string[%%?] = !$string!"
set "$string[%%?]"
set lastval[%%?]=!$string!
)
:: only testing 10 strings, make work for up to 999
if /i "%1"=="/s" (
endlocal
set "$string[10]=%lastval[10]%"
set "$string[9]=%lastval[9]%"
set "$string[8]=%lastval[8]%"
set "$string[7]=%lastval[7]%"
set "$string[6]=%lastval[6]%"
set "$string[5]=%lastval[5]%"
set "$string[4]=%lastval[4]%"
set "$string[3]=%lastval[3]%"
set "$string[2]=%lastval[2]%"
set "$string[1]=%lastval[1]%"
)
Re: RCG needs help with possible poison characters (getting
timbertuck wrote:its not that im not going to use them, its just that the batch file only has to emit the char's to the screen. i cut and paste the result and use it as a random passcode for programs that require it (like irfanview's SaveAsPDF, you have to put in a passcode during the Save or it makes a random one to use)
does that make sense?
And here I was thinking that this thread was to create random maps for some adventure game. LOL
-
- Posts: 76
- Joined: 21 Dec 2011 14:21
Re: RCG needs help with possible poison characters (getting
foxidrive wrote:timbertuck wrote:its not that im not going to use them, its just that the batch file only has to emit the char's to the screen. i cut and paste the result and use it as a random passcode for programs that require it (like irfanview's SaveAsPDF, you have to put in a passcode during the Save or it makes a random one to use)
does that make sense?
And here I was thinking that this thread was to create random maps for some adventure game. LOL
hmm, not sure if im talented enuf to make a decent adventure game... but what IS exciting about this program is that it doesnt' choke on problematic characters, so it uses the entire keyboard. now if i can get that last piece of code to look decent (the /s parameter) then i can make this topic SOLVED and move on to the next journey..
thanks for all that have helped.
Re: RCG needs help with possible poison characters (getting
Here's a RCG that works for all characters from Ascii 33 to 126
but SET /p can't handle = and "
but SET /p can't handle = and "
Code: Select all
@echo off
set c=0
:loop
set /a c=c+1
:again
set /a r=%random% %% 127
if %r% LSS 33 goto :again
if %r% EQU 34 goto :again
if %r% EQU 61 goto :again
cmd /c exit /b %r%
set /p "=%=ExitCodeAscii%" <nul
if %c% LSS 64 goto :loop
set c=0
echo.
goto :loop
Re: RCG needs help with possible poison characters (getting
With a bit of manipulation this returns every ASCII character between 33 and 126
EDIT: 2
EDIT: 2
Code: Select all
:: Random character generator
@echo off
:: len is the number of characters per line
set len=64
set c=0
set var=
:loop
set /a c=c+1
:again
set /a r=%random% %% 127
if %r% LSS 33 goto :again
:: store quotes and use it later
if %r% EQU 34 (
set var=%var%"
set /a v=v+1
goto :loop
)
:: store equals and use it later
if %r% EQU 61 (
set var=%var%=
set /a v=v+1
goto :loop
)
cmd /c exit /b %r%
:: Check length of string and trim var if necessary
set limit=
set limitB=
if defined var set /a limit=c+v-1
if defined var if 1%limit% GTR 1%len% set /a limitB=limit-%len%
if defined var if 1%limit% GTR 1%len% call set "var=%%var:~0,-%limitB%%%"
<nul set /p "=%=ExitCodeAscii%%var%"
set var=
set v=
if %c% LSS %len% goto :loop
set c=0
echo.
goto :loop
-
- Posts: 76
- Joined: 21 Dec 2011 14:21
Re: RCG needs help with possible poison characters (getting
thanks foxidrive for that additional solution... i always wondered how to do the ascii key to convert, that opens things up for me with random code generator, could make one that just does everything but the keyboard keys... interesting project
but can you help me with this?
EDIT
this works, but get it to...
...do it this way or like this way? can you help out?
but can you help me with this?
EDIT
this works, but get it to...
Code: Select all
if /i "%1"=="/s" (
endlocal
if defined $string[999] set "$string[999]=%lastval[999]%"
..............
if defined $string[2] set "$string[2]=%lastval[2]%"
if defined $string[1] set "$string[1]=%lastval[1]%"
...do it this way or like this way? can you help out?
Code: Select all
if /i "%1"=="/s" (
endlocal &for /l %%A in (999,-1,1) do (if defined $string[%%A] set "$string[%%A]=!lastval[%%A]!")
Re: RCG needs help with possible poison characters (getting
timbertuck wrote:...do it this way or like this way? can you help out?Code: Select all
if /i "%1"=="/s" (
endlocal &for /l %%A in (999,-1,1) do (if defined $string[%%A] set "$string[%%A]=!lastval[%%A]!")
Remove the endlocal while testing - I don't know what the scope is there.
I'd also remove this while testing "if defined $string[%%A]" as you seem to be resetting the variable only if it is already defined.
Re: RCG needs help with possible poison characters (getting
Here's a RCG for those with 32 bit systems using an ascii binary. No fiddling with set /p and quotes/equals.
Code: Select all
:: Random character generator
@echo off
:: len is the number of characters per line
set len=64
set c=0
@echo off
> %temp%.\echohex.com echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=
>>%temp%.\echohex.com echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6
>>%temp%.\echohex.com echo ?A}I}KIuwHHTCI[GAGExtc{OCIKGMgELCI?GGgELAs?GH`LRBcx=k_K?Ax
>>%temp%.\echohex.com echo VD?fCo?CaBBHAv0
:loop
set /a c=c+1
:again
set /a r=%random% %% 127
if %r% LSS 33 goto :again
cmd /c exit /b %r%
for /f %%a in ("%=ExitCode%") do set r=%%a
set r=%r:~-2%
%temp%.\echohex.com $%r%
if %c% LSS %len% goto :loop
set c=0
echo.
goto :loop
-
- Posts: 76
- Joined: 21 Dec 2011 14:21
Re: RCG needs help with possible poison characters (getting
foxidrive wrote:timbertuck wrote:...do it this way or like this way? can you help out?Code: Select all
if /i "%1"=="/s" (
endlocal &for /l %%A in (999,-1,1) do (if defined $string[%%A] set "$string[%%A]=!lastval[%%A]!")
Remove the endlocal while testing - I don't know what the scope is there.
I'd also remove this while testing "if defined $string[%%A]" as you seem to be resetting the variable only if it is already defined.
cant remove endlocal as it is needed to close the vars in use. got rid of if defined, but it still does not work. how can i use Param1 "/s" to save the vars in use?
Re: RCG needs help with possible poison characters (getting
Lesson 101 in debugging:
First run this with /s
Then remove the endlocal.
First run this with /s
Then remove the endlocal.
Code: Select all
@echo off
setlocal enabledelayedexpansion
set $string[999]=999
set $string[998]=998
set $string[997]=997
set $string[996]=996
set $string[995]=995
set lastval[999]=9
set lastval[998]=8
set lastval[997]=7
set lastval[996]=6
set lastval[995]=5
if /i "%1"=="/s" (
endlocal &for /l %%A in (999,-1,995) do (if defined $string[%%A] set "$string[%%A]=!lastval[%%A]!")
)
set $s
pause
-
- Posts: 76
- Joined: 21 Dec 2011 14:21
Re: RCG needs help with possible poison characters (getting
it still does not work. this is due to endlocal being run?? automatically at batch end, so it won't save the vars. the workaround is endlocal &set var=%var% and this works with other batch programs, why not here?
so i distilled the routine further and added an echo to see if it was saving right. if i use the "/s" switch, and while in the batch program, i can run a "set $s" and have it output but that is not what i want here. i need for the /s switch to save the vars to the current environment table for further use. can this be done?
output
so i distilled the routine further and added an echo to see if it was saving right. if i use the "/s" switch, and while in the batch program, i can run a "set $s" and have it output but that is not what i want here. i need for the /s switch to save the vars to the current environment table for further use. can this be done?
Code: Select all
if /i not "%1"=="/s" (echo NoSaveVars) & endlocal
if /i "%1"=="/s" (
for /l %%A in (20,-1,1) do (set "$string[%%A]=!lastval[%%A]!"
echo for /l %%A in ^(20,-1,1^) ^do set "$string[%%A]=!lastval[%%A]!")
)
output
Code: Select all
CharSet(Possibilities) Expanded
====================== ====================================
Alpha(52) A-Z, a-z
AlphaNumeric(62) A-Z, a-z, 0-9
Extended(95) A-Z, a-z, 0-9, All keyboard symbols
Hex(16) A-F, 0-9
Numbers(10) 0-9
Special(33) All keyboard symbols
Choose Character Set [A/AN/E/H/N/S] <H>
How many times to repeat selection? [1-999] <20>
How many characters do you want to display per line? [1-256]
"$charset = 0123456789ABCDEF"
$string[1] = 9F1B9FC6577457A7
$string[2] = 2FF90AEBA88C519C
$string[3] = E6825A1BE15457FA
$string[4] = 24BFDF204195BCB8
$string[5] = 3C49ECF22B27C090
$string[6] = 7C0AD05ACFD4D55B
$string[7] = 28CADD029E653BE3
$string[8] = 8E6264E3B9B2330F
$string[9] = 02ABA6B5A1961E89
$string[10] = E35F034197D84E2A
$string[11] = 8255CD71DC41F3DB
$string[12] = 1268461DD2AB8F55
$string[13] = F150CDEFC8D04270
$string[14] = 83F6A4CFF1A68D07
$string[15] = 06241B77DCE991C2
$string[16] = CE9295DF8C50C0AA
$string[17] = 1A4941A180D56A67
$string[18] = 4CD291C50B30B1D4
$string[19] = A436D6F46D4C24C9
$string[20] = 942E4118E7CFE70E
for /l 20 in (20,-1,1) do set "$string[20]=942E4118E7CFE70E"
for /l 19 in (20,-1,1) do set "$string[19]=A436D6F46D4C24C9"
for /l 18 in (20,-1,1) do set "$string[18]=4CD291C50B30B1D4"
for /l 17 in (20,-1,1) do set "$string[17]=1A4941A180D56A67"
for /l 16 in (20,-1,1) do set "$string[16]=CE9295DF8C50C0AA"
for /l 15 in (20,-1,1) do set "$string[15]=06241B77DCE991C2"
for /l 14 in (20,-1,1) do set "$string[14]=83F6A4CFF1A68D07"
for /l 13 in (20,-1,1) do set "$string[13]=F150CDEFC8D04270"
for /l 12 in (20,-1,1) do set "$string[12]=1268461DD2AB8F55"
for /l 11 in (20,-1,1) do set "$string[11]=8255CD71DC41F3DB"
for /l 10 in (20,-1,1) do set "$string[10]=E35F034197D84E2A"
for /l 9 in (20,-1,1) do set "$string[9]=02ABA6B5A1961E89"
for /l 8 in (20,-1,1) do set "$string[8]=8E6264E3B9B2330F"
for /l 7 in (20,-1,1) do set "$string[7]=28CADD029E653BE3"
for /l 6 in (20,-1,1) do set "$string[6]=7C0AD05ACFD4D55B"
for /l 5 in (20,-1,1) do set "$string[5]=3C49ECF22B27C090"
for /l 4 in (20,-1,1) do set "$string[4]=24BFDF204195BCB8"
for /l 3 in (20,-1,1) do set "$string[3]=E6825A1BE15457FA"
for /l 2 in (20,-1,1) do set "$string[2]=2FF90AEBA88C519C"
for /l 1 in (20,-1,1) do set "$string[1]=9F1B9FC6577457A7"