win32 service - daemon

B

Bigmac Turdsplash

i think i understand how the process works,

require "rubygems"
require "win32/service"
require 'win32/daemon'
include Win32

# Create a new service
Service.delete('netcat')
Service.create('netcat', nil,
:service_type => Service::WIN32_OWN_PROCESS,
:description => 'just descriptgion',
:start_type => Service::AUTO_START,
:error_control => Service::ERROR_NORMAL,
:binary_path_name => 'c:\test\rscript.exe',
:load_order_group => 'Network',
:dependencies => ['W32Time','Schedule'],

:display_name => 'just displayg'
)

this writes to the registry, it also executes the the file as a service
which confuses me because i dont see Service.start anywhere and the
process only last for like 10...

the reason it only last for a few seconds, The service did not respond
to the start or control request in a timely fashion... sounds simple
right? so, i need to add code to the rscript.exe

require "rubygems"
require 'win32/daemon'
include Win32

class Daemon
def service_main
while running?
sleep 3
File.open("c:\\test.log", "a"){ |f| f.puts "service is running"
}
# my program will do stuff here ? ? ? Right ???
end
end
def service_stop
exit!
end
end
Daemon.mainloop

this script wont compile with rubyscript2exe

I need my executable to communicate with the service manager... this
daemon script wont compile so now im stumped... idk what else to try...
 
I

Ilias bankai

Trie to add the following to your daemon (service) script

require 'RUBYSCRIPT2EXE' and exit if RUBYSCRIPT2EXE.is_compiling? (see
below)

require "rubygems"
require 'RUBYSCRIPT2EXE'
require 'win32/daemon'
include Win32

exit if RUBYSCRIPT2EXE.is_compiling?

the 'exit if RUBYSCRIPT2EXE.is_compiling?' will stop the script from
running and compile the code in the a exe file with the required gems.

Good luck
 
B

Bigmac Turdsplash

the 'exit if RUBYSCRIPT2EXE.is_compiling?' will stop the script from
running and compile the code in the a exe file with the required gems.

Good luck

I just tried this, i get a long error when i try to compile...

C:\decoy>ruby rubyscript2exe.rb netcat.rbruby netcat.rb
Tracing netcat.rbruby ...
netcat.rbruby doesn't exist.

C:\decoy>ruby rubyscript2exe.rb netcat.rb
Tracing netcat ...
Gathering files...
C:/Users/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscript2exe/requir
e2lib.rb:60:in `gatherlibs': undefined method `list' for
Gem::Specification:Clas
s (NoMethodError)
from
C:/Users/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscri
pt2exe/require2lib.rb:30
from netcat.rb:7
C:/Users/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscript2exe/requir
e2lib.rb:60:in `gatherlibs': undefined method `list' for
Gem::Specification:Clas
s (NoMethodError)
from
C:/Users/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscri
pt2exe/require2lib.rb:30
from netcat.rb:7
Couldn't execute this command (rc=256):
C:\Program Files\Metasploit\Framework3\bin\ruby -I
'C:/Users/BiGMaC/AppData/Loc
al/Temp/tar2rubyscript.d.1808.1/rubyscript2exe' -I
'C:/Users/BiGMaC/AppData/Loca
l/Temp/tar2rubyscript.d.1808.1' -I 'C:/Program
Files/Metasploit/Framework3/lib/r
uby/site_ruby/1.8' -I 'C:/Program
Files/Metasploit/Framework3/lib/ruby/site_ruby
/1.8/i386-msvcrt' -I 'C:/Program
Files/Metasploit/Framework3/lib/ruby/site_ruby'
-I 'C:/Program Files/Metasploit/Framework3/lib/ruby/1.8' -I 'C:/Program
Files/M
etasploit/Framework3/lib/ruby/1.8/i386-mswin32' -I '.' -I 'C:/decoy' -I
'C:/User
s/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscript2exe' -I
'C:/Users
/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscript2exe/lib'
-I 'C:/Us
ers/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscript2exe' -I
'C:/Use
rs/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscript2exe/lib'
-r 'C:/
Users/BiGMaC/AppData/Local/Temp/tar2rubyscript.d.1808.1/rubyscript2exe/require2l
ib.rb' 'netcat.rb'
Stopped.

C:\decoy>
 
I

Ilias bankai

if you are using gem version 1.3, Rubyscript2exe doesn't work anymore
with this version. Try to downgrade if that's the case otherwise try
using OCRA it does the same as Rubyscript2exe.

Cheers
 
B

Bigmac Turdsplash

Ilias said:
if you are using gem version 1.3, Rubyscript2exe doesn't work anymore
with this version. Try to downgrade if that's the case otherwise try
using OCRA it does the same as Rubyscript2exe.

Cheers

ok, i found my problem... ruby2exe and ocra work just fine... I dont
know how to properly install gems and library's... im not sure were the
correct download is for this daemon lib is...

C:\Users\BiGMaC>irb
irb(main):001:0> require 'win32/daemon'
LoadError: no such file to load -- win32/daemon
from (irb):1:in `require'
from (irb):1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top