Jump to content

GUI ICON from command


bytedeez
 Share

Recommended Posts

Did I really say VM?

I really said VM. GAH! That's what abbreviations will do to you.

WM. Window manager. I don't have a clue what Ubuntu comes with standard and I also don't have a clue what program, as it's bound to be a separate one, that WM uses for docking its apps.

Link to comment
Share on other sites

That might work i will test it.

Just from reading it i think this only working if the program already has a icon / can be called from the launcher search menu.

But i will test and let you know, either way Excellent Find! I can use the program for other needs as well! Thanks Cooper!

Edited by bytedeez
Link to comment
Share on other sites

In general yes that tool will work, but the downside to it is a proper Icon can not set. Still nice find!

EDIT: Scratch that! figured out you can set the icon after all. Thanks!

EDIT # 2: After setting Icon i tested the new created gui-icon. Unfortunately it did not work, from a google search it seems to be a common problem with the tool, Because i read in one post that indicator had to be installed for it to work properly, i installed it but had the same result.

Edited by bytedeez
Link to comment
Share on other sites

What you want to do is create a new .desktop file in /usr/share/applications/

touch /usr/share/applications/msfconsole.desktop

Then, you should paste the following in the above file, making sure to change your path.

[Desktop Entry]
Name=msfconsole
Comment=Metasploit msfconsole
Exec=/path/to/msfconsole
Icon=/path/to/icon.png
Terminal=true
Type=Application
Categories=Utility;Application;
That should do the trick. You should be able to use the new shortcut once you relog / reboot.
Best Regards,
Sebkinne
Link to comment
Share on other sites

Thanks Seb! I tried creating a .desktop file when i first started attempting to do this, but i gave it another go. but..

Its seems i am still having trouble.

here is my file in: /usr/share/applications

[Desktop Entry]
Name=msfconsole
Comment=Metasploit msfconsole
Exec=/usr/local/share/metasploit-framework/msfconsole.rb
Icon=/home/<username>/msf_icon.png
Terminal=true
Type=Application
Categories=Utility;Application;
Everything seems like it should run fine until i try to run the program, then it says an error has occured when trying to launch application.
I was thinking maybe it was my msfconsole file that was wrong but from what i am looking at it is right.
Here is the msfconsole file:
#!/usr/bin/env ruby
# -*- coding: binary -*-
#
# This user interface provides users with a command console interface to the
# framework.
#


#
# Standard Library
#


require 'pathname'


if ENV['METASPLOIT_FRAMEWORK_PROFILE'] == 'true'
  gem 'perftools.rb'
  require 'perftools'


  formatted_time = Time.now.strftime('%Y%m%d%H%M%S')
  root = Pathname.new(__FILE__).parent
  profile_pathname = root.join('tmp', 'profiles', 'msfconsole', formatted_time)


  profile_pathname.parent.mkpath
  PerfTools::CpuProfiler.start(profile_pathname.to_path)


  at_exit {
    PerfTools::CpuProfiler.stop


    puts "Generating pdf"


    pdf_path = "#{profile_pathname}.pdf"


    if Bundler.clean_system("pprof.rb --pdf #{profile_pathname} > #{pdf_path}")
      puts "PDF saved to #{pdf_path}"


      Rex::Compat.open_file(pdf_path)
    end
  }
end


#
# Project
#


# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/generators/rails/app/templates/script/rails#L3-L5
require Pathname.new(__FILE__).realpath.expand_path.parent.join('config', 'boot')
require 'metasploit/framework/command/console'


Metasploit::Framework::Command::Console.start

I also tried creating the file while being logged in as root but had similar results.

I also tried making the file "executable" but didn't get any further that way wither.

Edited by bytedeez
Link to comment
Share on other sites

If you place a regular shell script next to the .rb file which does nothing more than feed the .rb into the ruby interpreter and have that run by the icon, does that work? Maybe the're using a (more) restrictive means of running the program. If anything, you can add some echo lines to the script and feed the output of the .rb program into a logfile of sorts from the .sh file to see what's up.

Link to comment
Share on other sites

Thats out of my league Cooper. LOL

I know very basic programming in python and Java. And the basics as to how code is written I.E. methods, variables, functions and so on but that is it. Although I've edited scripts, i have never written one from a blank canvas.

If i could write one i was thinking that maybe i needed a few lines that started services and then called the console. I see in the code above at the end it has this line

require 'metasploit/framework/command/console'

Wouldn't this call it as well, if i wrote a script that started services and then called that^^^ or is that the same as msfconsole?....(don't laugh, as i know i'm probably talking out my ass)

Edit: right now i'm just using armitage, but i have a few other programs that are command only that i'm trying to assign an icon to.....I honestly i didn't think it would be difficult to accomplish when i first started looking into creating a gui icon.

Edited by bytedeez
Link to comment
Share on other sites

As root, create a file named /usr/local/share/metasploit-framework/msfconsole.sh and make it executable. Edit it so it reads

#!/bin/bash
ruby /usr/local/share/metasploit-framework/msfconsole.rb > /var/log/msfconsole.log

Have your icon execute the .sh file instead of the .rb and if it works, just remove the "> /var/log/msfconsole.log" bit from the script. If it doesn't work, see what gets written to that log file for clues.

Edit: Looking at what's being run and how it's running it, check out that first line in the .rb script:

#!/usr/bin/env ruby

That runs 'ruby'. The env bit allows messing with the environment variables - ignore for now. The point is that it's running _just_ 'ruby' as opposed to /path/to/ruby which you normally see. On most shells this is probably not a problem but on more restrictive shells your local environment-setting script (i.e. .bashrc) doesn't get run so the path within which the ruby binary resides doesn't get added to the path before the script runs and the outcome is an error because it can't find the interpreter needed. I'm fairly confident this is the problem you're having.

Edited by Cooper
Link to comment
Share on other sites

hmmmm...

created the .sh file.

touch /usr/local/share/metasploit-framework/msfconsole.sh

copy and pasted the code above into it then..

chmod +x msfconsole.sh

Then i edited the .Desktop file

[Desktop Entry]
Name=msfconsole
Comment=Metasploit msfconsole
Exec=/usr/local/share/metasploit-framework/msfconsole.sh
Icon=/home/<username>/Downloads/msf_icon.png
Terminal=true
Type=Application
Categories=Utility;Application;

Then i migrated to the applications folder and tried opening the application, it opened a terminal but immediately closed.

I checked the log file but nothing was there.

I then decided to execute the script as normal.

./msfconsle.sh 

then i received this error in the terminal:

/usr/local/share/metasploit-framework# ./msfconsole.sh ruby: No such file or directory -- /usr/local/share/metasploit-framework/msfconsole.rb (LoadError)

So again i checked the log file, it remained empty.

The part that confuses me about the above error is the "no such file or directory". When it obviously there. lol

EDIT: ok so i started going back through all the steps to make sure all the links were correct. The only thing i noticed was that even though msfconsole was a ruby file. I could not find any link or file that represented it with the file extension .rb, so i remove the .rb from the script and...drum roll please..... BAM!! It worked like a charm.

I tried removing the script and creating the original .desktop file as described by Seb but did not work.

Therefore you were correct Master Cooper!

Edited by bytedeez
Link to comment
Share on other sites

After further testing, it seems that once i launched the application it stalls at starting "Starting Metaspliot Framework.../".

The Log file seems to contain the next step in msfconsole:

[0m[36m[0m[37m
  Metasploit Park, System Security Interface
  Version 4.0.5, Alpha E
  Ready...
  > [1maccess security[0m
  access: PERMISSION DENIED.
  > [1maccess security grid[0m
  access: PERMISSION DENIED.
  > [1maccess main security grid[0m
  access: PERMISSION DENIED....and...
  [31mYOU DIDN'T SAY THE MAGIC WORD!
  YOU DIDN'T SAY THE MAGIC WORD!
  YOU DIDN'T SAY THE MAGIC WORD!
  YOU DIDN'T SAY THE MAGIC WORD!
  YOU DIDN'T SAY THE MAGIC WORD!
  YOU DIDN'T SAY THE MAGIC WORD!
  YOU DIDN'T SAY THE MAGIC WORD![0m
[0m

       =[ [33mmetasploit v4.11.0-dev [core:4.11.0.pre.dev api:1.0.0][0m]
+ -- --=[ 1382 exploits - 777 auxiliary - 223 post        ]
+ -- --=[ 356 payloads - 37 encoders - 8 nops             ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

[4mmsf[0m [0m> 

Checked it serveral times and each time it contains one of the variants of msfconsole.

Aha removed "> /var/log/msfconsole.log" from the script, Sense it seemed to be throwing my session into the log file.

Got on here to report that everything is working good, then noticed you said to remove it above..LOL!

Edited by bytedeez
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...