Commit 529a0cc7 authored by Philip Linghammar's avatar Philip Linghammar
Browse files

Merge dd2b28ae into master

parents f97b9560 dd2b28ae
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@
  * [Meterpreter for Post-Exploitation](getting_meterpreter_shell.md)
  * [Privilege Escalation - Linux](privilege_escalation_-_linux.md)
  * [Privilege Escalation - Windows](privilege_escalation_windows.md)
  * [Privilege Escalation - Powershell](privilege-escalation-powershell.md)
  * [Escaping Restricted Shell](escaping_restricted_shell.md)
  * [Bypassing antivirus](bypassing_antivirus.md)
  * [Loot and Enumerate](loot.md)
+79 −1
Original line number Diff line number Diff line
@@ -514,7 +514,85 @@ crontab -l
crontab -e
```

## 8. Devices
## 8. Devices/disks/partitions

First some terminology. A `drive`is a physical storage device, just as a hard disk, solid state drive, or usb. In Linux these drives are represented as special file system objects called "device". They are found under `/dev`.A physical storage unit, a drive, can be divided up in to multiple logical storage units, these are called `partitions`. So they are just digital divisions of the drive. In linux a device are often named something like sda, sdb, sdc. And the partions of those devices are numbered. So one partion might be called `sda1`, and another `sda2`. These can then be found under `/dev/sda1` and `/dev/sda2`.

You can view the devices and their partions with the command `lsblk`



### Formating disks

If you want to do it the easy way, just open `gnome-disks`.

To format disks we are going to use the program `parted`. It can be used with its own shell or by running commands. So you can just run parted, and you will enter the parted interface. But here we are going to run the commands instead. 



```
# Make sure you know which device you are working with, they can change name between boots
lsblk
```

**Partition standard**

First we have to choose a partition standard. The modern and mostly used is gpt, and older is msdos.

```
# This will destroy all the data on the on the disk
sudo parted /dev/sda mklabel gpt
```



**Create a new partition**

```
sudo parted --align optimal /dev/sda mkpart primary 0% 100%
```

This command creates a new partition \(mkpart\), which is of type primary, that takes up the space between 0-100%. Which means we will only have one partition.



Now you can see your new partition with `lsblk`.

**Format the partition with a specific filesystem**

Now that we have a partition we need to add a filesystem to it.There are many different types of filesystems. ext4 is common for linux. While windows uses NTFS, and mac uses HFS Plus. exFAT can be understood by all three OS:s, something that might be useful to USB:s. 

```
# For linux
sudo mkfs.ext4 /dev/sda1
# Supposedly work on linux, mac and windows. But fails for me on my tests on Mac 
sudo mkfs.vfat /dev/sda1
```

**Remove partition**

```
# if you want to remove partition 1
sudo parted /dev/sda rm 1
```



**Mount it**

Now you can just mount the parition somewhere on your filesystem

```
# Mount it
sudo mkdir /mnt/here
sudo mount /dev/sda1 /mnt/here

# Unmount it
sudo umount /mnt/here

```



List all devices

+51 −10
Original line number Diff line number Diff line
@@ -9,7 +9,11 @@ PowerShell is Windows new shell. It comes by default from Windows 7. But can be

## Basics

So a command in PowerShell is called **cmdlet**. To get help on how to use a **cmdlet** while in PowerShell, the man-page, you do:
So a command in PowerShell is called **cmdlet**. The cmdlets are created using a verb and a noun. Like `Get-Command`, Get is a  verb and  Command is a noun. Other verbs can be: remove, set, disable, install, etc.



To get help on how to use a **cmdlet** while in PowerShell, the man-page, you do:

```
Get-Help    <cmdlet    name    |    topic    name>
@@ -28,6 +32,37 @@ get-help get-command
$PSVersionTable
```

### Fundamentals

With get-member you can list all the properties and methods of the object that the command returns.

```
Get-Member
For example:
Get-Command | Get-Member
Get-Process | Get-Member
```



Select-XXX

```
Select-object
```



#### Variables

```
$testVar = "blabla"
```





**Wget / Download a file**

```
@@ -42,8 +77,6 @@ Select string can be used like grep
get-command | select-string blabla
```



**General commands that can be used on objects**

```
@@ -51,10 +84,6 @@ measure-object -words
get-content fil.txt | measure-object words
```





### Working with filesystem

**List all files in current directory**
@@ -62,18 +91,19 @@ get-content fil.txt | measure-object words
```
get-childitem
gci

List hidden files too
gci -Force

List all files recurisvely
gci -rec

Count the files
(get-childitem).count
List all files but exclude some folders
gci -exclude AppData | gci -rec -force
```



### Working with files

```
@@ -86,7 +116,6 @@ Count lines of file
Select specific line in a file (remember that it starts from 0)
(gc .\file.txt)[10]
gc .\file.txt | Select -index 10
       
```

### Services
@@ -106,6 +135,18 @@ Get-AdDomainController
Get-AdComputer
To see a list of all properties do this
get-adcomputer ComputerName -prop *

Get AD Users
Get-ADUser -f {Name -eq 'Karl, Martinez'} -properties *

Get all AD Groups
Get-ADGroup -filter *



Resolve DNS
Resolve-DNSname 10.10.10.10

```


+11 −0
Original line number Diff line number Diff line
## Privilege Escalation with Powershell



```
What modules are available to us?
get-module -listavailable
```