Metasploit: Issue with upgrading a low privilege shell (sessions -u)

Setup info: I don’t believe this is the issue as I regularly update my system. I’ll add one piece of information as an example. If you would really like to the rest then I can add more in later

metasploit v5.0.89-dev

Payload: I used a custom python script to create a reverse shell from the victim’s computer to the attacker. No problem with the low priv shell in netcat or metasploit. If anyone wants to take a look
at the script I can upload it to github and share the link(thought its nothing special, I’d prefer to send the link privately to keep the script as less spread as possible).

Exact Steps I took:

msf5 > use multi/handler
msf5 exploit(multi/handler) > set payload windows/x64/shell_reverse_tcp
payload => windows/x64/shell_reverse_tcp
msf5 exploit(multi/handler) > set LPORT 549 
LPORT => 443
msf5 exploit(multi/handler) > set LHOST 10.8.210.314
LHOST => 10.9.139.110
msf5 exploit(multi/handler) > run

(*) Started reverse TCP handler on 10.9.139.110:443 
(*) Command shell session 1 opened (10.9.139.110:443 -> 10.9.0.1:50071) at 2020-05-30 22:31:25 -0400


Login: password
You have a shell have fun #> background

Background session 1? (y/N)  y
msf5 exploit(multi/handler) > sessions -u 1
(*) Executing 'post/multi/manage/shell_to_meterpreter' on session(s): (1)

The Issue:

(*) Upgrading session ID: 1
(*) Starting exploit/multi/handler
(*) Started reverse TCP handler on 10.9.139.110:4433 
(-) Post failed: NoMethodError undefined method `reverse!' for nil:NilClass
(-) Call stack:
(-)   /usr/share/metasploit-framework/lib/msf/core/session/provider/single_command_shell.rb:136:in `shell_command_token_win32'
(-)   /usr/share/metasploit-framework/lib/msf/core/session/provider/single_command_shell.rb:84:in `shell_command_token'
(-)   /usr/share/metasploit-framework/lib/msf/core/post/common.rb:147:in `cmd_exec'
(-)   /usr/share/metasploit-framework/lib/msf/core/post/windows/powershell.rb:32:in `have_powershell?'
(-)   /usr/share/metasploit-framework/modules/post/multi/manage/shell_to_meterpreter.rb:161:in `run'

Note: I have taken a look at some of the files, but they seem to be coded in ruby(something I am not familiar with) and the error seems to be related to multiple files, so I have no clue how to really debug this. There also seems to be similar issues posted on github if it helps.

ubuntu – Ruby program start from console but fail from service & shell script

I’m a developer.
I have a ruby program and I have to launch it as daemon.

This program has a shell script

#!/bin/bash
dir=$(pwd)
while sleep 60
do
    if pgrep -fa bin/bot >/dev/null
    then
        echo 'works'
    else
     pkill -f bin/bot
        ruby $dir/bin/bot >> $dir/logs/bot.log 2>&1 &!
    fi

    if pgrep -fa mongod >/dev/null
    then
        echo 'mongo works'
    else
        mongod --fork --logpath /var/log/mongod.log
    fi
done

I’m not the author.
I fix the ruby script.

If I launch in console from the right folder

ruby $dir/bin/bot >> $dir/logs/bot.log 2>&1 &!

The script works.

When I use the shell script in a service I have ‘mongo works’ but my ruby process fail.
Why?

grub2 – Alert! /dev/sda5 does not exist. Dropping to a shell

I installed Ubuntu 20.04 on my laptop but when I start it’s shown this error

ALERT! /dev/sda5 does not exist. Dropping to a shell

BusyBox v1.30.1 (Ubuntu v1:1.30.1-4ubuntu6) built-in shell (ash)
Enter help for a list of built-in commands.

(initramfs)

I tried to fix following some steps like to restore grub and mount the correct ‘section’ but I have the same problem.

I also reinstalled the operational system but nothing changes.

shell – Feedback on my bash backup script

I have this little server at home, which is hosting some websites, school stuff and a minecraft server. I made this backup script and I would like some feedback since I’m not very good at scripting.

#!/bin/bash
# declare folders to backup
dirs=(
    "/home/ferre/Minecraft"
    "/var/lib/automysqlbackup/daily"
);

# backup names
names=(
  "Minecraft"
  "Mysql"
);                                                                                                                                                                                                                                        

# backup folder
backupdir="/mnt/backup";

# backup algorithm
for (( i=0; i<=$(( ${#dirs(*)} -1 )); i++))
do
  # info
  echo "starting backup of ${names(i)}";

  # create folder
  path="${backupdir}/${names(i)}";
  $(mkdir -p "$path");

  # create backup
  file="${path}/$(date +%F).tar";
  $(tar -czf "$file" --absolute-names "${dirs(i)}");

  # reporting
  result=$?;
  if ( $result -eq 0 ); then
    echo "SUCCESS";
  elif ( $result -eq 1 ); then
    echo "WARNING some files where changed while copying!";
  else
    echo "FATAL ERROR";
  fi
done

bash: Shell script to create a folder with file name and copy files inside

I have a list that looks like this

ABC_100.0_k_1x1x1.xyz
ABC_100.0_k_1x1x1.txt
ABC_100.0_k_2x2x2.xyz
ABC_100.0_k_2x2x2.txt
ABC_100.0_k_10x10x10.xyz
ABC_100.0_k_10x10x10.txt
ABC_600.0_k_1x1x1.xyz
ABC_600.0_k_1x1x1.txt
ABC_1000.0_k_1x1x1.xyz
ABC_1000.0_k_1x1x1.txt

I want to write a script that creates the following folders

ABC_100.0_k_1x1x1
ABC_100.0_k_2x2x2
ABC_100.0_k_10x10x10
ABC_600.0_k_1x1x1
ABC_1000.0_k_1x1x1

I have tried the following

#!/bin/bash

for file in *_???.*_?x?x?.*
    do
        dir=${file%}
        dir=${dir%.*}
        mkdir -p "./$dir" &&
        scp -r "$file" "./$dir"
done

But I only receive the folders

ABC_100.0_k_1x1x1
ABC_600.0_k_1x1x1

What am I doing wrong? Maybe this is stupid, but this was my first attempt at shell scripting.

Gnome shell extension: intellihide mode does not work in the same application

I change my intellihide mode in dash-to-dock to & # 39; FOCUS_APPLICATION_WINDOWS & # 39;, somehow it doesn't work if the overlay and non-overlay app is the same, so dash / dock will still hide though focus window be the only one that doesn't overlap. Is there any solution for this?

18.04 – How to run gsettings from a root shell?

In a recent QA, I discovered how to set up custom shortcuts using gsettings set. Now I am trying to automatically do those settings on first boot.

I have established /etc/rc.local run some script every time the laptop is started, as recommended by (this answer) modified so that it only runs if it has never been run before.
The same script works when run as a user from a terminal, but I still haven't figured out how to make it take effect when run from rc.local.

I guess the problem has to do with the fact that rc.local it runs as root and not as the unprivileged user (which is called generic on my machine)

This answer advises using sudo -H -u generic .
When I run my script (with set -x) from terminal it seems to run successfully and when gsettings get The values ​​I modified return the value I have set this way. But once I open the Settings > Devices > Keyboard and scroll down to the custom shortcuts, it will show the previously set values ​​(or nothing, if not set). At this time, re-querying the same key using the same terminal as before will also return the previous value.
However, running any of the commands in my script directly in the terminal will produce additional results:

generic@segelbrot~$ sudo -Hu generic gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding 'Right'

(process:5633): dconf-CRITICAL **: 22:05:08.571: unable to create file '/home/generic/.cache/dconf/user': Permission denied. dconf will not work properly.

(process:5633): dconf-CRITICAL **: 22:05:08.572: unable to create file '/home/generic/.cache/dconf/user': Permission denied. dconf will not work properly.

(process:5633): dconf-CRITICAL **: 22:05:08.592: unable to create file '/home/generic/.cache/dconf/user': Permission denied. dconf will not work properly.
generic@segelbrot:~$

The file /home/generic/.cache/dconf/user exists but belongs to root:root and you have permissions -rw-------.
Take possession using sudo chown generic:generic /home/generic/.cache/dconf/user correct this symptom (I don't know why it was so). But still, setting the link using the above command has no effect on the values ​​displayed in the Gnome configuration GUI nor on the effect it should have (Modifying the keyboard shortcut that triggers some custom command). Not even when I reload gnome using AltF2 and enter "r".
Running the same command without sudo from a terminal instantly has the desired effects.

How can i run my gsettings set Commands on the first start of my ubuntu 18.04 as if it were the (only) user generic running it?


The relevant part of my script is this:

#!/bin/bash
# This is supposed to be run as root on first boot by placing it in /etc/rc.local
# It automatically exits if it has been run before, by detecting the presence of the .canary.done file
# Logs to stdout.
set -x
CANARYFILE="/install/firstboot.canary.done"
if ( ! -f $CANARYFILE ); then
    echo '---'
    echo '--- STARTING FIRSTBOOT.sh ---' 
    echo '---'
    # create canary file so that we won't run again the next boot
    touch $CANARYFILE
else
    exit 1
fi

# --- actual script contents below this line ---
USERNAME='generic'

# -- setup gnome shortcuts --
# install wmctrl to allow moving windows to a different GNOME workspace without switching to that workspace as per my askubuntu questions
apt-get -y install wmctrl
# and set up the settings... but as the user, not as root.
sudo -Hu $USERNAME gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding 'Left'
sudo -Hu $USERNAME gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name 'move to first workspace'
sudo -Hu $USERNAME gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command 'bash /opt/workspacemagic/send_to_zeroeth.sh'
sudo -Hu $USERNAME gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding 'Right'
sudo -Hu $USERNAME gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name 'move to next workspace'
sudo -Hu $USERNAME gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command 'bash /opt/workspacemagic/send_to_next.sh'
# and link to them. This OVERWRITES the array.
#  important: paths start and end with a slash
sudo -Hu $USERNAME gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "('/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/')"

shell – Why does a custom prompt on Linux (debian server) not work as expected?

I am setting up a (Debian) server in Virtualbox, I am customizing the prompt, but I have a problem. When I write in prompt customization it is poorly formed.

enter the image description here

This happens when I type in the message, overwrite the message or when I enter or the key (up arrow / down arrow). Why?

My settings are as follows:

PS1='33(1;37mH($(hostname -I | grep -E -o "192.168.(0-9){1,3}.(0-9){1,3}")) (33(1;31mu33(1;37m) <@> 33(1;34mw33(1;37m >> '

enter the image description here

enter the image description here

Why it happens? How can I solve it?

shell – How to long press on Android 4.1.2 and 4.2.2 using ADB?

I found out that the following command doesn't run on Android 4.1.2 and 4.2.2, but it runs from Android 4.4+.

input touchscreen swipe x1 y1 x2 y2 [duration]

I'm using my old Android 4.1.2 and 4.2.2 in kiosk mode and I need my script to hold down in some areas, but I can't get the above command to do the trick by myself, but it works perfectly on my other android 4.4.2 and 4.4.4?
My question is, what files should I copy from my Android 4.4.2 to my Android 4.2.2 in order for the above command to work on Android 4.2.2? Or is there some other way to do it?
NOTE: I don't need sendevent method please i just need input touchscreen swipe method. Thank you

Reset PIN from adb shell

I have forgotten the PIN of a device but I have access to a root shell with adb shell and su

Is there a way to remove the PIN lock from the screen or change it?