How to debug Oracle 11g packages/procedures in docker with SQL Developer? - docker

I'm running an Oracle 11g image (https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g) on a docker container.
I'm creating the container with the debug option as explained:
docker run --name oracle-xe-11g -idt -p 1521:1521 -p 49161:8080 -e ORACLE_ALLOW_REMOTE=true oracleinanutshell/oracle-xe-11g /bin/bash
After that I logged in the container as sudo, configured the listener.ora with the correct hostname, everything following this guide (it's in pt-Br, but the commands are easy to understand)
http://loredata.com.br/2017/08/31/rodando-o-oracle-no-docker/
I can connect with SQL Developer and with my main application running in a Wildfly server, but for support purposes I need to debug some package and stored procedures.
I compiled all my packages and procedures to allow debugging, gave the debug permissions to the user, but when I try to debug a procedure in a package using the SQL Developer default debug options I get the following error:
Conectando ao banco de dados SFW_DOCKER.
Executando PL/SQL: ALTER SESSION SET PLSQL_DEBUG=TRUE
Executando PL/SQL: CALL DBMS_DEBUG_JDWP.CONNECT_TCP( '127.0.0.1', '20587' )
ORA-30683: falha ao estabelecer conexão com o depurador
ORA-12541: TNS:não há listener
ORA-06512: em "SYS.DBMS_DEBUG_JDWP", line 68
ORA-06512: em line 1
Processo encerrado.
Desconectando do banco de dados SFW_DOCKER.
It says there's no listener, but I'm sure everything is running fine.
I also tried to run in ports 4000-4999 exposing them in the create container command and forcing SQL Developer to use them, but I get the same error.
Anyone can help me with this question?

To solve try:
Use IPv4 from your local machine
Set 'Debugging Port Range' from 4000 to 4000
Check the option 'Prompt for Debugger Host for Database Debugging'
SQL Developer -> Tools -> Preferences -> Debugger
Debugger configuration

I solved it by setting DatabaseDebuggerDisableJDWP=true in ide.properties. On linux this can be done with this:
find ~/.sqldeveloper/ -name ide.properties -type f -exec sh -c "echo 'DatabaseDebuggerDisableJDWP=true' >> {}" \;

Related

NSE: failed to initialize the script engine:

I'm new to VAPT and I'm using GUI for windows, this is what I got when I used this script from nmap online guide [nmap -p 80 --script http-default-accounts.routers xx.xx.xx.xx]. I borrowed the script from here : https://nmap.org/nsedoc/scripts/http-default-accounts.html
[nmap -p 80 --script http-default-accounts.routers xx.xx.xx.xx]
Nmap output begins below this line:
NSE: failed to initialize the script engine:
C:\Program Files (x86)\Nmap/nse_main.lua:823: 'http-default-accounts.category' did not match a category, filename, or directory
stack traceback:
[C]: in function 'error'
C:\Program Files (x86)\Nmap/nse_main.lua:823: in local 'get_chosen_scripts'
C:\Program Files (x86)\Nmap/nse_main.lua:1315: in main chunk
[C]: in ?
QUITTING!
Nmap uses the --script option to introduce a boolean expression of script names and categories to run. To provide arguments to these scripts, you use the --script-args option. So what you wanted to run was: nmap --script http-default-accounts --script-args http-default-accounts.category=routers
In most cases, you can leave the script name off of the script argument name, as long as you realize that another script may also be looking for an argument called category. For example: nmap --script http-default-accounts --script-args category=routers
If you are using this command:
nmap --script vulscan.nmap-vulners -sV {target}
Then use the following command instead.
nmap -sV --script vulners {target}
For me, it worked.
As for Nmap 7.90 [2020-10-03] changelog, dealing with directories has changed:
[GH#2051]Restrict Nmap's search path for scripts and data files. NMAPDATADIR, defined on Unix and Linux as ${prefix}/share/nmap, will not be searched on Windows, where it was previously defined as C:\Nmap . Additionally, the --script option will not interpret names as directory names unless they are followed by a '/'. [Daniel Miller]
So basically if we said you are using kali and this is your old command:
nmap --script vulscan -sV ###.###.###.###
It should become like:
nmap --script vulscan/ -sV ###.###.###.###
adding a / after directory name.

monitoring the number of RDP users using nagios core?

I'm using Nagios Core 4.3.4. Is there any way to monitor the number of users connected to the server RDP on a Windows server like nrpe check_users? Please tell me if you have.
you would have to write your own check for this.
In your check you could call a powershell script on the server (but it depends on your windows version):
ipmo RemoteDesktop # 1. import the remotedesktop module
$(Get-RDUserSession).count # 2. print the count of the session
But there is another approach mentioned on monitoring-portal.org site. It's in german, so I try to translate:
1.) read window performance counters with nsclient:
c:\program files\nsclient\nsclient++.exe -noboot CheckSystem listpdh >counters_list.txt
2.) define the command (where -s $USER7$ is the passphrase to establishe the connection
define command{
command_name check_nt_Counter_User
command_line $USER1$/check_nt -H $HOSTADDRESS$ -s $USER7$ -p 12489 -v COUNTER -l $ARG1$ -w $ARG2$ -c $ARG3$ -d SHOWALL
}
3.) define the service
define service{
service_description RDP-Sessions
host_name TerminalSrv
use sometemplate
check_command check_nt_Counter_User!"\\Terminalservices\\active sessions","RDP-User active","users"!18!20
notes get count of active sessions
process_perf_data 1
notifications_enabled 0
}

Query regarding Zookeeper Windows API start/stop, using Zk as a windows service(using prunsrv)

I am using zookeeper in my product(3.3.3).
While working with zookeeper on Windows, I am creating a service(using prunsrv) ,
I have few queries and issues. Listed them all,
Issues:
1) zkServer.cmd didn’t start on Win server 2008 machine & Win 7 Enterprise(64 bit both), had to replace the following line,
java "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
to
java "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%"
And it worked, could it be fixed in some other way?
2) In the zoo.cnf I specified the dataDir, still it creates some other directory (bin/zookeeper-3.4.5zookeeper-3.4.5data/ version-2/snapshot) and stores the snapshots there.
Queries:
1) There is no start/stop with zkServer.cmd as it is in zkServer.sh, so basically it is started with zkServer.cmd but to stop I do a Ctrl+C/Z
So if I start the process, it is a foreground process and gets killed when I do a ctrl+C
2) I have to create a zookeeper service, and I am using prunsrv to do that. I figured out the following 2 ways to do so.
a)
prunsrv //IS//Zookeeper --DisplayName=" ZOOKEEPER Service" --Description=" ZOOKEEPER Service" --Startup=auto --StartMode=exe --StartPath=%ZOOKEEPER_HOME% --StartImage=%ZOOKEEPER_HOME%\bin\zkServer.cmd --StopTimeout=5 --LogPath=%LOGS_DIR% --LogPrefix=zookeeper --LogLevel=Info --PidFile=zookeeper.pid --StdOutput=auto --StdError=auto
b)
cd %ZOOKEEPER_HOME%\bin\
call "%~dp0zkEnv.cmd"
set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
prunsrv //IS//Zookeeper --DisplayName=" ZOOKEEPER Service" --Description=" ZOOKEEPER Service" --Jvm="%JVM_DLL%" --JvmOptions=!JAVA_OPTS! --Environment=zookeeper.log.dir=%ZOO_LOG_DIR%;zookeeper.root.logger=%ZOO_LOG4J_PROP%; --Startup=auto --LibraryPath=%LIB_DIR% --StartMode=jvm --Classpath=%CLASSPATH% %ZOOMAIN% %ZOOCFG% --StartClass=org.apache.zookeeper.server.quorum.QuorumPeerMain --StartMethod=start --StopMode=jvm --StopClass=org.apache.zookeeper.server.quorum.QuorumPeerMain --StopMethod=stop --StopTimeout=10 --LogPath=%LOGS_DIR% --LogPrefix=zookeeper --LogLevel=Info --PidFile=zookeeper.pid --StdOutput=auto --StdError=auto
basically in the second approach I am myself doing all tasks done by the zkServer.cmd
=>> My Query is in the second step(2b), that to stop the service there should be a stop method exposed, so that when I stop the service it is called.
So right now if I create a service and start it, ZK runs fine, but stopping it takes indefinitely, so I have to go and kill the process.
Is there some stop() for the same, I see a shutdown() but there is no description for it
I went through the class org.apache.zookeeper.server.quorum.QuorumPeerMain, here the main() is the start method( if my understanding is correct), and there should be some method to shutdown the process.
Just got the following link
https://issues.apache.org/jira/browse/ZOOKEEPER-1122, exposes a start/stop, but the stop has some issues
it throws the following error:
E:\zookeeper-3.4.5\zookeeper-3.4.5\bin>zkServer.cmd stop
"JMX enabled by default"
"Using config: E:\zookeeper-3.4.5\zookeeper-3.4.5\bin\..\conf\zoo.cfg"
"Stopping zookeeper ... "
ERROR: The process with PID 452 (child process of PID 4) could not be terminated.
Reason: This is critical system process. Taskkill cannot end this process.
ERROR: The process with PID 4 (child process of PID 0) could not be terminated.
Reason: Access is denied.
ERROR: The process with PID 0 (child process of PID 0) could not be terminated.
Reason: This is critical system process. Taskkill cannot end this process.
STOPED
I am running this stop command on a Administrator console.
E:\zookeeper-3.4.5\zookeeper-3.4.5\bin>tasklist | findstr "java"
java.exe 10324 Console 1 36,036 K.
Any help would be highly appreciated
So what you want to do is run Zookeeper as a Windows service. I had the same requirement, here is the solution I have chosen:
Prereqs: Zookeeper & prunsrv
Set ZOOKEEPER_SERVICE environment variable to the name of the windows service to create, and ZOOKEEPER_HOME to the path to the zookeeper home folder. Then,
prunsrv.exe "//IS//%ZOOKEEPER_SERVICE%" ^
--DisplayName="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
--Description="Zookeeper (%ZOOKEEPER_SERVICE%)" ^
--Startup=auto --StartMode=exe ^
--StartPath=%ZOOKEEPER_HOME% ^
--StartImage=%ZOOKEEPER_HOME%\bin\zkServer.cmd ^
--StopPath=%ZOOKEEPER_HOME%\ ^
--StopImage=%ZOOKEEPER_HOME%\bin\zkServerStop.cmd ^
--StopMode=exe --StopTimeout=5 ^
--LogPath=%ZOOKEEPER_HOME% --LogPrefix=zookeeper-wrapper ^
--PidFile=zookeeper.pid --LogLevel=Info --StdOutput=auto --StdError=auto
Add a zkServerStop.cmd file in zookeeper bin folder with the following content:
#echo off
setlocal
TASKLIST /svc | findstr /c:"%ZOOKEEPER_SERVICE%" > %ZOOKEEPER_HOME%\zookeeper_svc.pid
FOR /F "tokens=2 delims= " %%G IN (%ZOOKEEPER_HOME%\zookeeper_svc.pid) DO (
#set zkPID=%%G
)
taskkill /PID %zkPID% /T /F
del %ZOOKEEPER_HOME%/zookeeper_svc.pid
endlocal
(Of course it needs the two environment variables ZOOKEEPER_HOME & ZOOKEEPER_SERVICE to be set)
Hope it helps,
Guillaume.

erlang R16B01 and Windows CMD

I'm windows 7 user and try to learn erlang and here's the time when I get to the paragraph where I have to deal with creating and naming nodes. I used to start erlang emulator from shortcut and don't know how to start it from command prompt window to use -name or -sname commands, and when I try to use
net_kernel:start([node,shortnames]).
command I get
{error,
{{shutdown,
{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}},
{child,undefined,net_sup_dynamic,
{erl_distribution,start_link,[[node,shortnames]]},
permanent,1000,supervisor,
[erl_distribution]}}}
=INFO REPORT==== 23-Aug-2013::15:28:03 ===
Protocol: "inet_tcp": register/listen error: econnrefused
error. I thought it was because of windows firewall and turned it off, but nothing has changed. So can someone answer what's going on?? And if you don't mind teach me how can I start erlang from CMD and use -name and -sname commands.
1) make sure you have in the path, program files \ erlang \ bin \ erl
2) open the command prompt and type
3) erl -sname dilbert
-name = for fully qualified name [dilbert#mypc.maydomain.com]
-sname for short name [dilbert#mypc]
this will give you
% erl -sname dilbert
(dilbert#mypc)1> node().
dilbert#mypc
I am, most of the time, a windows user, and as it is not natural in this environment to use command windows, I used to write some command files to invoke werl (the usual VM interface in windows). But I stopped that, because it is less convenient and less flexible than the command window, and also because I very often need other command line tools like ping, ipconfig, or git...
I join an example of the code you can use:
launch_werl.bat:
echo off
echo Select a project:
echo 1: project 1
echo 2: project 2
echo 3: project 3
set /p proj=
goto label%proj%
:label1
d:
cd "\git\project1"
set prname=proj1
goto end
:label2
d:
cd "\documents and Settings\user\My Documents\path\to\some\code"
set prname=proj2
goto end
:label3
d:
cd "\git\proj3"
set prname=PLC
goto end
:end
start werl -sname %prname% -pa "./ebin"
echo on

Tsung Distributed Client Load Testing - Simple HTTP Requests

I am trying to create a distributed client network using Tsung. I have a cluster of 14 different machines. I want to use m01 as the server and machines m02 and m03 as the clients (or simulated users).
Here is what I wrote:
<!-- Client side setup -->
<clients>
<client host="localhost" maxusers="400" cpu="1"><ip value="192.168.1.2"/></client>
<client host="m03" maxusers="400" cpu="1"><ip value="192.168.1.3"/></client>
</clients>
The server I am targeting is defined here:
<!-- Server side setup -->
<servers>
<server host="192.168.1.1" port="5000" type="tcp"></server>
</servers>
Whenever I try to run this, I get the following error:
Host key verification failed.
For notes purposes, m02 is a localhost that I am running tsung on.
I have installed tsung and erlan on all machines and have done various testing to make sure that I can run non-distributed tests.
I am not sure how to move from here.
Tsung Cluster configuration.
For configuration of Tsung cluster you need to have nodes (different computers with same operation system and with same version of Tsung).
All nodes should have possibility to access to master node without promting password. For this operation you have to generate ssl certificates in master node and then add public key in all slave nodes. Follow the commands below:
Generate the certificate in master node:
ssh-keygen -t rsa
Copy the files to all nodes home directories (in our example there are 3 nodes):
scp ./id_rsa.pub USERNAME#NODE_1_IP_ADDRESS:~
scp ./id_rsa.pub USERNAME#NODE_2_IP_ADDRESS:~
scp ./id_rsa.pub USERNAME#NODE_3_IP_ADDRESS:~
Add public key in all nodes:
cat id_rsa.pub >> .ssh/authorized_keys
After successful keygen generation and installation on all nodes you should check via ssh command the access to all nodes. First time login via ssh is required either you should get Host key verification failed.
example :
please do this:
ssh [thesameusernamewhichisintsungtestplan]#yournodehostname
NOTE: Your all nodes' /etc/hosts should have the cluster and Test Servers credentials.
Tsung distributed load testing is based on SSH shell distribution.
Make sure you set up your SSH system so that you can ssh without password prompt (with key) from master to all the slave nodes.
From Tsung documentation:
for distributed tests, you need an ssh access to remote machines without password (use a RSA/DSA key without pass-phrase or ssh-agent) (rsh is also supported)
Have you ever ssh'd to the machines you are trying to use from the machine you are on?
ubuntu#ip-10-168-221-101:~/sessions$ tsung -f project.xml -l logs/tsung.log start
Starting Tsung
"Log directory is: /home/ubuntu/sessions/logs/20120830-1008"
Host key verification failed.
Host key verification failed.
Host key verification failed.
Host key verification failed.
^C
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
^Cubuntu#ip-10-168-221-101:~/sessions$ grep client project.xml
<clients>
<client host="localhost"/>
<client host="ip-10-161-74-53"/>
<client host="ip-10-168-154-136"/>
<client host="ip-10-168-15-66"/>
<client host="ip-10-168-86-249"/>
</clients>
the mean inter-arrival time between new clients and the phase
ubuntu#ip-10-168-221-101:~/sessions$ ssh ip-10-161-74-53 erl
The authenticity of host 'ip-10-161-74-53 (10.161.74.53)' can't be established.
ECDSA key fingerprint is d0:92:3c:f1:56:99:c8:34:8b:0f:99:e8:10:7e:69:a6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ip-10-161-74-53,10.161.74.53' (ECDSA) to the list of known hosts.
Eshell V5.8.5 (abort with ^G)
1> ^C
ubuntu#ip-10-168-221-101:~/sessions$ for d in $(grep client project.xml | grep ip | sed 's/<client host="\([^"]\+\)"\/>/\1/'); do ssh $d cat /etc/hosts; done
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
[...]
ubuntu#ip-10-168-221-101:~/sessions$ tsung -f project.xml -l logs/tsung.log start
Starting Tsung
"Log directory is: /home/ubuntu/sessions/logs/20120830-1013"
Profit!"
1 Use this on server(master) to check if the SSH login without password is ok:
ssh client-002 erl
2 If it's not ok, just do this to keep your public key file is the newest:
ssh-copy-id your-hostname
PS:
If you setup your SSH login without password OK, then DO NOT use ssh-keygen to generate new public key.
Steps
1.Reboot the VMs/machines and start new session
2.Remove lines of /home/user/.ssh/known_hosts related to machines m01,m02 and m03 from each of the machines
3.modify /etc/hosts files of all of them to contain ip address and hostname/fqdn/shortname of m01,m02 and m03
4.Copy the contents of publickey in to /home/user/.ssh/authorized_keys file and copy the private key file in to /home/user/.ssh/ folder. Generate new private and public keys using keygen if not generated.
5.(important step)Now run command:" ssh m03 " from m01 and m02 .It is important to use the same name(or hostname) in ...(in your .xml file) , in /etc/hosts file and while doing ssh. (the hostname you use for ssh will be added in known_hosts file). Similarly do in other two machines.
Reference: http://cryolite.iteye.com/blog/378758 (please translate)
"Host key verification failed." error will never appear again :)

Resources