Skip to content
This repository was archived by the owner on Sep 23, 2022. It is now read-only.

Commit d379772

Browse files
author
nerdofcode
committed
Merge branch 'master' of github.com:NerdOfCode/admin-panel
2 parents 4f4d300 + fa079a2 commit d379772

4 files changed

Lines changed: 59 additions & 18 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# admin-panel
2+
This is a very sucky admin panel that is in pre-pre-pre-pre-pre-pre-pre-pre-alpha stages. So far it can run shell commands, and basic MySQL queries. It has a simple UI, and the passwords in the database are now hashed, as opposed to the plaintext they used to be.
3+
4+
## Set-Up
5+
6+
First create a MySQL database by running:
7+
8+
```MySQL
9+
CREATE DATABASE database_name_goes_here;
10+
```
11+
12+
To set it up, create a MySQL table, with the fields `name` and `password`, to do so run:
13+
14+
```MySQL
15+
CREATE TABLE users(name VARCHAR(30) NOT NULL, password VARCHAR(50) NOT NULL);
16+
```
17+
Then put your desired username in the `name` field, and the password in the `password` field.
18+
The password must be PHP hashed, to do so, run:
19+
20+
```shell
21+
php -r 'echo password_hash("password", PASSWORD_DEFAULT);'; echo ""
22+
```
23+
on a LAMP install, make sure to put this password back in the MySQL table...
24+
25+
Finally, change the values in the <b>user.php</b> file to match your own.

index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646
$result = mysqli_query($db, $query);
4747
$row = mysqli_fetch_array($result);
4848
$password=$row['password'];
49-
if($user_password == $password && $user_name != ""){
49+
if(password_verify($_POST['passwd'], $password)){
5050
$_SESSION['status'] = "1";
5151
header("Location: /options.php");
5252
die();
53-
}else if($user_password != $password && $user_name != ""){
53+
}else{
5454
echo "An error has occured... Please try again later";
5555
$_SESSION['status'] = "0";
5656
}

mysql_exec.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,30 @@
3333
</body>
3434

3535
<?php
36-
$udb=$_POST['mysql_get'];//Database
37-
$user=$_POST['username'];
38-
$pass=$_POST['password'];
39-
$query=$_POST['myquery'];//Commands
40-
$host=$_POST['host'];
41-
//Set all current values as session variables below
42-
$_SESSION['saved_info']="1";$_SESSION['udb']="$udb";$_SESSION['mysql_user']="$user";$_SESSION['mysql_pass']="$pass";$_SESSION['query']="$query";$_SESSION['host']="$host";
43-
$db = mysqli_connect($host,$user,$pass,$udb) or die("<p style=\"color:red;\"><b>Error: </b> connection to MySQL failed. Please re-enter information and try again.</p>");
44-
mysqli_query($db, $query) or die("Unable to access MYSQL");
45-
$result = mysqli_query($db, $query);
46-
$row = mysqli_fetch_array($result);
47-
$column=$row['password'];
48-
echo "<b>Query Result: $column</b><br>";
49-
$mysqli_close($db);
36+
$udb=$_POST['mysql_get'];//Database
37+
$user=$_POST['username'];
38+
$pass=$_POST['password'];
39+
$query=$_POST['myquery'];//Commands
40+
$host=$_POST['host'];
41+
//If the variables are not empty, continue
42+
if (isset($udb, $user, $pass, $query, $host)){
43+
//Set all current values as session variables below
44+
$_SESSION['saved_info']="1";$_SESSION['udb']="$udb";$_SESSION['mysql_user']="$user";$_SESSION['mysql_pass']="$pass";$_SESSION['query']="$query";$_SESSION['host']="$host";
45+
echo "<br> MySQL Query results: <br>";
46+
include("data.php");
47+
$databaseName = $_POST[mysql_get];
48+
$query = $_POST[myquery];
49+
$db = mysqli_connect($host,$user,$pass,$udb) or die("<p style=\"color:red;\"><b>Error: </b> connection to MySQL failed. Please re-enter information and try again.</p>");
50+
mysqli_query($db, $query) or die("Unable to access MYSQL DataBase");
51+
$result = mysqli_query($db, $query);
52+
$row = mysqli_fetch_all($result, MYSQLI_ASSOC);
53+
$stringArray = json_encode($row);
54+
$stringArray = str_replace(",", "<br>", $stringArray);
55+
$stringArray = str_replace(array('[', ']', '}', '"'), "", $stringArray);
56+
$stringArray = str_replace("{", "<br>", $stringArray);
57+
$stringArray = str_replace(":", ": ", $stringArray);
58+
echo $stringArray;
59+
$mysqli_close($db);
60+
}
5061
?>
5162
</html>

shell.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
$cwd=getcwd();
2323
echo "<br>Current directory: $cwd<br>";
2424
$shell = $_POST['query_box'];
25-
$run = exec("$shell");
26-
echo "<br><b>Output: $run</b><br>";
25+
if (!empty($_POST['query_box'])) {
26+
$run = exec("$shell");
27+
echo "<br><b>Output: </b><br>";
28+
echo "<pre>$run</pre>";
29+
}else{
30+
echo "<b>Nothing has been run yet.</b>";
31+
}
2732
?>
2833
</body>
2934
</html>

0 commit comments

Comments
 (0)