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

C# 

Switch Case command and argument? [!(command) (argument)]

I am using a switch statement to grab commands from elsewhere, and I was wondering about something. If I wanted a command like '!blahblah [url]', how would I make a case for that?

This is what I really need, but it doesnt work
Code
case "blahblah" + cmd:
    break;
http://msdn.microsoft.com/en-us/library/ms228388.aspx
(Apr 12, 2014 04:19 PM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote:  http://msdn.microsoft.com/en-us/library/ms228388.aspx

I don't see how that helps, could you explain more?

For example, If I wanted to make a command that resolved IP's via Skype, the user typing to command would have to input a skype name, which can be anything. Like, '!resolve boneritus'. How can I collect this comand with a case (after removing the '!' of course)
Use strcmp? Compare strings? You need to include cstring library.
Bazinga.
I can't remember off the top of my head, but can't you make a temp string beforehand.

String str = "blahblahblah" + cmd;

switch(str){
case peniscake:
break;
}
(Apr 12, 2014 04:23 PM)OG Gangsta Wrote:  I don't see how that helps, could you explain more?

For example, If I wanted to make a command that resolved IP's via Skype, the user typing to command would have to input a skype name, which can be anything. Like, '!resolve boneritus'. How can I collect this comand with a case (after removing the '!' of course)

There is a whole example on that link on what you need to do.
Think about it, you want to SPLIT up a string into different parts.

Edit: Nevermind, read OP wrong. Just do this: string joined = "Test" + "ing";
PHP Code

<?php 
string
[] str = "blah|" + cmd;
swtich(str[0])
[
case 
cmd:
break;
} 

Just use the | as a delimiter
(Apr 12, 2014 05:50 PM)Geekie Wrote:  
PHP Code

<?php 
string
[] str = "blah|" + cmd;
swtich(str[0])
[
case 
cmd:
break;
} 

Just use the | as a delimiter

That might've worked, but my cmd is a normal string, not a string[]
You need to split the string.

Note: Not exactly what you want I don't think but could possibly help.
Code
string str = "blah|" + cmd;
switch (str.Split('|')[0])
{
    case "blah":
    string cmd = str.Split('|')[1];
    break;
}

Try that OP. Also so I can help better, what is this for?
(Apr 12, 2014 07:11 PM)Dongahh Wrote:  You need to split the string.

Note: Not exactly what you want I don't think but could possibly help.
Code
string str = "blah|" + cmd;
switch (str.Split('|')[0])
{
    case "blah":
    string cmd = str.Split('|')[1];
    break;
}

Try that OP. Also so I can help better, what is this for?
I am making a private botnet for me and a few buddies, and I am trying to add a ddos command.

As in '!ddos 85.291.384.822'


(Apr 12, 2014 07:11 PM)Dongahh Wrote:  You need to split the string.

Note: Not exactly what you want I don't think but could possibly help.
Code
string str = "blah|" + cmd;
switch (str.Split('|')[0])
{
    case "blah":
    string cmd = str.Split('|')[1];
    break;
}

Try that OP. Also so I can help better, what is this for?

It didn't work :( One day.... One day.
Case values must be constant. In other words you can't have
switch(myString)
{
case "Hello" + otherString:
break;
}
[Image: jlscvfi.png]
(Apr 12, 2014 09:31 PM)NETExplorer Wrote:  Case values must be constant. In other words you can't have
switch(myString)
{
case "Hello" + otherString:
break;
}

I realize that, I'm looking for an alternative
(Apr 12, 2014 07:16 PM)OG Gangsta Wrote:  I am making a private botnet for me and a few buddies, and I am trying to add a ddos command.

As in '!ddos 85.291.384.822'



It didn't work :( One day.... One day.

So your commands will be formatted like !(command) (argument)?

If so then here's an example;
Code
string str = "!ddos 85.291.384.822";
switch (str.Split('!')[1])
{
    case "ddos":
      string ip = str.Split(' ')[1];
      break;

}

Not the cleanest code nor would I usually do it like that but don't have access to Visual Studio.
(Apr 13, 2014 12:29 AM)Dongahh Wrote:  So your commands will be formatted like !(command) (argument)?

If so then here's an example;
Code
string str = "!ddos 85.291.384.822";
switch (str.Split('!')[1])
{
    case "ddos":
      string ip = str.Split(' ')[1];
      break;

}

Not the cleanest code nor would I usually do it like that but don't have access to Visual Studio.
That is good, but that will only allow the user to boot that one IP. Im trying to make it so you can input any IP, and it will still go into the case.
(Apr 13, 2014 12:47 AM)OG Gangsta Wrote:  That is good, but that will only allow the user to boot that one IP. Im trying to make it so you can input any IP, and it will still go into the case.

WTF are you talking about?,
You can code a priv8 botnet and you don't know how to concat strings. 😧

I would suggest you to learn c# before doing anything...
[Image: jfhDhRz.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by ImDeepWithWindowsJul 4, 2020 06:19 PM 0 167 Jul 4, 2020 06:19 PM
Last Post: ImDeepWithWindows
[Shell] by friiz1337May 14, 2020 04:09 AM 2 207 May 14, 2020 04:09 AM
Last Post: sed-i
[Shell] by Nulla MisericordiaFeb 14, 2020 02:23 PM 0 163 Feb 14, 2020 02:23 PM
Last Post: Nulla Misericordia