Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

Checking command-line variable vs a variable on an online document

If I have a script

Code
@echo off
var1=var1
var2=var2
var3=incorrectvar

Is there any way I could check those variables against a text document on a website?

The text document (or any file extension, it doesn't really matter) would list the variables like;

Code
var1=var1
var2=var2
var3=var3

Therefore var1 and var2 would print success messages whilst var3 would print an error message.

Essentially, I'm trying to make it so I can give people premium keys to my program, but the program will only allow this premium key if it's listed on the site.

Example script:

Code
@echo off
set key=goodkey1

Example site file:

Code
goodkey1
goodkey2

and since goodkey1 matches with something on the site, the premium access would be allowed.
But if the script was as follows;

Code
@echo off
set key=badkey

Since "badkey" isn't listed on the site file the program would deny premium access.
Is this possible?
In order to check it you would have to download the file to local storage on your PC (I am pretty sure this can be done with a command like bitsadmin, if not vbs) then check for the variable.
(Mar 16, 2015 05:39 PM)Nakamoto. Wrote:  In order to check it you would have to download the file to local storage on your PC (I am pretty sure this can be done with a command like bitsadmin, if not vbs) then check for the variable.

I know there is a way to download files (I've used wget before) but I was hoping I could do it all online so I could make it as secure as possible.

However it seems as if that'll have to work.
(Mar 16, 2015 06:38 PM)DoxinYourBotnetM8 Wrote:  I know there is a way to download files (I've used wget before) but I was hoping I could do it all online so I could make it as secure as possible.

However it seems as if that'll have to work.

Not with just batch, sadly. You could possibly POST the variables with WGET and then analyze the response, but that's beyond my knowledge.
If you want to be secure, don't use batch. Anyone can look at your batch file and get the address for the document you are comparing to. For me what comes to mind would be java to do this just because I have been working on that a little bit. Java will allow you to pull data from a text file that resides on the internet and allow you to manipulate that data as needed. I am not strong enough with java to give anymore specifics than that but it is a starting point.
There's no place like ~/
Oh come on, this IS possible in pure batch and you guys should know it by now!

BITS will allow you to download the webpage.
for /f lets you analyse the text file you downloaded.
If statements to check for equality.

Boom!
(Mar 17, 2015 03:40 AM)annikk.exe Wrote:  Oh come on, this IS possible in pure batch and you guys should know it by now!

BITS will allow you to download the webpage.
for /f lets you analyse the text file you downloaded.
If statements to check for equality.

Boom!

Yes possible but not secure as he is asking. A programming language where the script is compiled and not visible would give an extra layer of security. If the user can read the text file that is being accessed by the script then they will know the key or whatever it is to unlock his program.
There's no place like ~/
Yeah, it's woefully insecure, that is true. Totally possible though. :>
Technically couldn't I just have the document permissions hidden in a .HTACCESS file?
That way it could still be downloaded, but not viewed.

And afterwards I could just have the program delete the file so they wouldn't be able to view it on their desktop.

I could also do some sort of really shitty encryption system;

Code
set a=www
set b=coldgaming.net
set c=file
set d=key
set e=.
set f=/
set g=http
set h=:

%g%%h%%f%%f%%a%%e%%b%%f%%d%%c%

(or something similar, I might've messed up)
Nah, it's because somewhere in your batch file you're going to have something like:

Code
if %keyValid% == true call :launchPremiumProgram

The user can simply edit it to:

Code
if 1 == 1 call :launchPremiumProgram

Obfuscation is one option, but it's tricky to do it well unless you're an expert.
(Mar 17, 2015 01:56 PM)annikk.exe Wrote:  Nah, it's because somewhere in your batch file you're going to have something like:

Code
if %keyValid% == true call :launchPremiumProgram

The user can simply edit it to:

Code
if 1 == 1 call :launchPremiumProgram

Obfuscation is one option, but it's tricky to do it well unless you're an expert.

Ay, I forgot the user can edit the program himself..

How would I go about converting my program from Batch to java?
(Mar 17, 2015 02:16 PM)DoxinYourBotnetM8 Wrote:  Ay, I forgot the user can edit the program himself..

How would I go about converting my program from Batch to java?

Hm... I'll tell you once you tell me how to turn my Java into ASM. (It's a rhetorical question)
(Mar 17, 2015 02:16 PM)DoxinYourBotnetM8 Wrote:  Ay, I forgot the user can edit the program himself..

How would I go about converting my program from Batch to java?

Here is a good place to start.
programmer's Heaven

afaik there is no software to convert batch to java but it is a good language to learn as it is cross platform and widely used.
There's no place like ~/
(Mar 17, 2015 02:16 PM)DoxinYourBotnetM8 Wrote:  Ay, I forgot the user can edit the program himself..

How would I go about converting my program from Batch to java?

Not possible due to how the two lannguages operate.

Batch is a series of commands ran one-after-another, each command is either a subroutine of the actual interpreter (the more simple commands AFAIK), or an external program the interpreter knows the location of (more complex commands AFAIK). Batch is an interpreted language, that is the interpreter reads over your script and executes it line-by-line, each line is read by the interpreter and the interpreter does some other code to fulfill the purpose of your command.

Java is an object-oriented language, data and elements you work with are represented as objects in memory, the class you write your code in is represented as an object stored on a stack. Each "command", "instruction" or "keyword" in Java edits the stack or an item on the stack (not in that way, this way implies that it's linear, the object is pushed to the stack then edited, it's more so the object is built based on the data you give in the form of "instructions" or "keywords" and then is pushed to the stack). Java is a compiled language, when you write your source code, to execute it you must compile it to JVM bytecode, which is so similar to the code your CPU executes natively (machine code, assembly, ASM), but a little different (JVM bytecode contains instructions that the CPU does not understand, so the JVM interprets the bytecode and translates it to a native language the CPU can understand, this is how Java is platform-independent (works on any system regardless of OS as long as you have a working JRE installed)).

The two languages operate worlds different from each other, have differing models for how they process instructions, handle variables different (in Batch a variable is basically a "keyword" which gets replaced by a value, in Java a variable on the stack is a reserved index on the stack for a value to be pushed to, same goes for in the memory), and overall are worlds different.

So you cannot translate from Batch to Java, at all. Not possible. You'll need to learn Java and write this from scratch I'm afraid.
I wasn't talking about converting the file over just like that. I know I'll need to learn Java. I was just hoping you could give me some references for similar Java code that I could work with (eg: what would the equivalent of echo be?)

I would hope it wouldn't be as simple as a program that can convert batch to Java. That'd take the fun out of it ;)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by MiguelSanchezFeb 1, 2022 08:17 AM 0 160 Feb 1, 2022 08:17 AM
Last Post: MiguelSanchez
[Python] by MiguelSanchezJan 22, 2022 07:01 AM 0 147 Jan 22, 2022 07:01 AM
Last Post: MiguelSanchez
[Python] by VUEDUEJun 3, 2021 04:20 PM 5 223 Jun 3, 2021 04:20 PM
Last Post: Freddy Kruеger