How to fix the “CredSSP encryption Oracle remediation” error?

To fix the CredSSP Encryption Oracle Remediation error using Command Prompt, follow these steps for your client computer:

  1. Open the Command Prompt as an administrator.
  2. Type “reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters /f /v AllowEncryptionOracle /t REG_DWORD /d 2” and press Enter.
  3. Sometimes, it may require to restart your computer for the changes to take effect.

This should resolve the CredSSP Encryption Oracle Remediation error using Command Prompt on Windows.

Source: https://tryrdp.com/blog/credssp-encryption-oracle-remediation-fixed/

Xammp MySQL Error Bad file descriptor

  1. Rename folder mysql/data to mysql/data_old
  2. Make a copy of mysql/backup folder and name it as mysql/data
  3. Copy all your database folders from mysql/data_old into mysql/data (except mysql, performance_schema, and phpmyadmin folders)
  4. Copy mysql/data_old/ibdata1 file into mysql/data folder
  5. Start MySQL from XAMPP control panel

source: https://stackoverflow.com/questions/8843776/mysql-table-is-marked-as-crashed-and-last-automatic-repair-failed

In this process, restoring the ibdata1 file in MySQL, it will only restore the InnoDB tablespace, which contains the data and indexes of your tables. The ibdata1 file does not include the stored procedures, triggers, or other database objects.

Stop Mysql Service. Go to data_old folder (eg. D:\xampp\mysql\data_old\mysql) and copied proc,proc.MAI,proces_priv,procs_priv.MAI files to the new data\mysql (eg. D:\xampp\mysql\data_old\mysql) folder. Now, start Mysql Service. Thus, you should get back your stored procedures also.

How to get HTTP GET and POST request and response header with message body on a specific port using tcpdump

There are tcpdump filters for HTTP GET & HTTP POST (or for both plus message body):

Run man tcpdump | less -Ip examples to see some examples

Here’s a tcpdump filter for HTTP GET (GET = 0x47, 0x45, 0x54, 0x20):

sudo tcpdump -s 0 -A ‘tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420’
Here’s a tcpdump filter for HTTP POST (POST = 0x50, 0x4f, 0x53, 0x54):

sudo tcpdump -s 0 -A ‘tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)’
Monitor HTTP traffic including request and response headers and message body (source):

tcpdump -A -s 0 ‘tcp port 80 and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0)’
tcpdump -X -s 0 ‘tcp port 80 and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0)’
For more information on the bit-twiddling in the TCP header see: String-Matching Capture Filter Generator (link to Sake Blok’s explanation).

with mentioning interface e.g:

tcpdump -i eth0 -A -s 0 ‘tcp port 80 and (((ip[2:2] – ((ip[0]&0xf)<<2)) – ((tcp[12]&0xf0)>>2)) != 0)’

Note: visually we can do the same work with the Wireshark tool.

Source: https://stackoverflow.com/questions/4777042/can-i-use-tcpdump-to-get-http-requests-response-header-and-response-body

SSL certification error while accessing web service with java

If you want to manually check the web service is responding or not, first check with curl

curl –location –request POST “https://localhost:port/webservices/API?WSDL&#8221; –header “Content-Type: text/xml” –header “Authorization: Basic U1lTVVN2GjpzeKU1c2VyMDA=” –data @D:\curl_ami.txt -k

Use -k or –insecure for avoiding certification checking. Here curl_ami.txt is your actual API payload.

For invalid certificates, you may encounter errors like “PKIX path building failed” and “unable to find valid certification path to requested target” in your java application.

If, the api returns expectedly, go for the permanent solution. Follow the steps below.

  1. Go to API URL in your browser like https://localhost:port/webservices/API?WSDL
  2. click on site (lock) icon left to address, select “Connection in secure” -> “Certificate is Valid”->”Details” -> “Export/Copy to File” and save in format “Der-encoded binary, single certificate”.
  3. Now you have file with keystore and you have to add it to your JVM. Determine location of cacerts files, eg. C:\Program Files \Java\jre1.8.0_161\lib\security\cacerts.
  4. Next import the my_ssl_cert.cer file into cacerts in command line (may need administrator command prompt):

keytool -import -alias my_ssl_cert -keystore "C:\Program Files \Java\jre1.8.0_161\lib\security\cacerts" -file my_ssl_cert.cer

You will be asked for the password which default is changeit

Restart your JVM/PC.

Now, Access the API through your application, hopefully, it will work. Enjoy!

Tomcat invalid character found in request target: the valid characters are defined in RFC 7230 and RFC 3986. How to Resolve this issue?

This is expected behavior.

A severe security issue was reported which was caused by improper URL validation (https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-6816) .  This was fixed and subsequently patched in most Tomcat versions since 7.0.88. 

In 11.7.4 Progress AppServer for OpenEdge (PASOE) shipped with Tomcat version 8.5.34, which includes this patch. 

When using some extended characters in the query string or path of the request, this now results in the below error:
Bad Request. java.lang.IllegalArgumentException: Invalid character found in the request target.  
The valid characters are defined in RFC 7230 and RFC 3986.
The safest and most appropriate solution for this is to url encode strings that contain the special characters defined in the above specs.  At present the characters that need to be URL encoded consists of the below list:
" < > [ \ ] ^ ` { | }
If it is NOT possible to URL encode the offending characters (for instance the user is using a web browser that doesn't respect the RFC specs), the below workaround, while still not secure, allows bypassing this error.

Caution: Using this workaround could open the application to be exploited, in conjunction with a proxy that also permitted the invalid characters but with a different interpretation, to inject data into the HTTP response.

By manipulating the HTTP response, the attacker could poison a web-cache, perform an XSS attack and/or obtain sensitive information from requests other than their own.

Resolution:

In tomcat, server.xml conf modify the following

<Connector port="<port>"
           protocol="HTTP/1.1"
           maxThreads="150"
           connectionTimeout="20000"
           redirectPort="443"
           relaxedQueryChars="|{}[],"
	   relaxedPathChars="|{}[],"
	   URIEncoding="UTF-8"
/>

Restart, tomcat. Done.

Source: https://knowledgebase.progress.com/articles/Article/Getting-400-errors-calling-PASOE-application-after-upgrade-to-11-7-4

How To Find Largest Top 10 Files and Directories On Linux

# du -a /u01 | sort -n -r | head -n 10

[root@unified-prepaid-test alert]# du -a /u01 | sort -n -r | head -n 10
208944256 /u01/app
208944256 /u01
208931912 /u01/app/oracle
201583992 /u01/app/oracle/diag
201578628 /u01/app/oracle/diag/tnslsnr/unified-prepaid-test/listener
201578628 /u01/app/oracle/diag/tnslsnr/unified-prepaid-test
201578628 /u01/app/oracle/diag/tnslsnr
141829796 /u01/app/oracle/diag/tnslsnr/unified-prepaid-test/listener/alert
59748552 /u01/app/oracle/diag/tnslsnr/unified-prepaid-test/listener/trace
7311348 /u01/app/oracle/product/19.0.0/dbhome_1
[root@unified-prepaid-test alert]#

In apache tomcat, how to configure WebApp folder in a different path other than the default one?

 1. Create a file name <yourapp>.xml inside location    ${CATALINE_HOME}/conf/Catalina/localhost

 2. Add the below content in the xml file created above

<Context displayName="yourapp" 
     docBase="/path/to/yourapp"
     path="/yourapp"
     reloadable="true" />

3. Restart tomcat

In tomcat 9, path variable is not supported. For that case the Cotext Path should be like <Context displayName=”your app name” docBase=”/path/to/your app” reloadable=”true”/>

For that case, the name of your context XML (${CATALINE_HOME}/conf/Catalina/localhost/yourapp.xml) will be the context root for your application. So, you will access the application as below

http://localhost:8080/yourapp/

e.g.: ${CATALINE_HOME}/conf/Catalina/localhost/dpk-web-service.xml
<Context displayName=”DPK Web Service” docBase=”/opt/apps/dpkwebservice” reloadable=”true” />
assces as following,
http://localhost:8080/dpk-web-service

Installing XAMPP on Windows for PHP and Oracle Database

source: https://blogs.oracle.com/opal/post/installing-xampp-on-windows-for-php-and-oracle-database
Author: Christopher Jones

Today’s guest post comes from Tianfang Yang who’s been working with the Oracle Database extensions for PHP.

This post shows how to install XAMPP on Windows to run PHP applications that connect to a remote Oracle Database. (If you use macOS, see Installing XAMPP on macOS for PHP and Oracle Database).

XAMPP is an open source package that contains Apache, PHP and many PHP ‘extensions’. One of these extension is PHP OCI8 which connects to Oracle Database.

To install XAMPP:

Download “XAMPP for Windows” and follow the installer wizard. I installed into my D: drive.
Start the Apache server via the XAMPP control panel.
screenshot of XAMPP control panel
Visit http://localhost/dashboard/phpinfo.php via your browser to see the architecture and thread safety mode of the installed PHP. Please note this is the architecture of the installed PHP and not the architecture of your machine. It’s possible to run a x86 PHP on an x64 machine.
screenshot of PHP configuration showing the PHP OS architecture as x86
[Optional] Oracle OCI8 is pre-installed in XAMPP but if you need a newer version you can download an updated OCI8 PECL package from pecl.php.net. Pick an OCI8 release and select the DLL according to the architecture and thread safety mode. For example, if PHP is x86 and thread safety enabled, download “7.2 Thread Safe (TS) x86”. Then replace “D:\xampp\php\ext\php_oci8_12c.dll” with the new “php_oci8_12c.dll” from the OCI8 PECL package.
screenshot of PECL OCI8 download page

Edit “D:\xampp\php\php.ini” and uncomment the line “extension=oci8_12c”. Make sure “extension_dir” is set to the directory containing the PHP extension DLLs. For example,
Copy code snippet
Copied to ClipboardError: Could not CopyCopied to ClipboardError: Could not Copy
extension=oci8_12c
extension=oci8_12c
Copy code snippet
Copied to ClipboardError: Could not CopyCopied to ClipboardError: Could not Copy
extension_dir=”D:\xampp\php\ext”
extension_dir=”D:\xampp\php\ext”
Download the Oracle Instant Client Basic package from OTN. Select the correct architecture to align with PHP’s. For Windows x86 download “instantclient-basic-nt-12.2.0.1.0.zip” from the Windows 32-bit page.
screenshot of Oracle Instant Client download page
Extract the file in a directory such as “D:\Oracle”. A subdirectory “D:\Oracle\instantclient_12_2” will be created. Add this subdirectory to the PATH environment variable. You can update PATH in Control Panel -> System -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> PATH. In my example I set it to “D:\Oracle\instantclient_12_2”.
Restart the Apache server and check the phpinfo.php page again. It shows the OCI8 extension is loaded successfully.
screenshot of PHP configuration page showing a section for OCI8 If you also run PHP from a terminal window, make sure to close and reopen the terminal to get the updated PATH value.
To run your first OCI8 application, create a new file in the XAMPP document root “D:\xampp\htdocs\test.php”. It should contain:
Copy code snippet
Copied to ClipboardError: Could not CopyCopied to ClipboardError: Could not Copy
<?php

error_reporting(E_ALL);
ini_set(‘display_errors’, ‘On’);

$username = “hr”; // Use your username
$password = “welcome”; // and your password
$database = “localhost/orclpdb”; // and the connect string to connect to your database

$query = “select * from dual”;

$c = oci_connect($username, $password, $database);
if (!$c) {
$m = oci_error();
trigger_error(‘Could not connect to database: ‘. $m[‘message’], E_USER_ERROR);
}

$s = oci_parse($c, $query);
if (!$s) {
$m = oci_error($c);
trigger_error(‘Could not parse statement: ‘. $m[‘message’], E_USER_ERROR);
}
$r = oci_execute($s);
if (!$r) {
$m = oci_error($s);
trigger_error(‘Could not execute statement: ‘. $m[‘message’], E_USER_ERROR);
}

echo “\n”;
$ncols = oci_num_fields($s);
echo “\n”;
for ($i = 1; $i <= $ncols; ++$i) {
$colname = oci_field_name($s, $i);
echo ” \n”;
}
echo “\n”;

while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
echo “\n”;
foreach ($row as $item) {
echo “\n”;
}
echo “\n”;
}
echo “

“.htmlspecialchars($colname,ENT_QUOTES|ENT_SUBSTITUTE).”
“;
echo $item!==null?htmlspecialchars($item, ENT_QUOTES|ENT_SUBSTITUTE):” “;
echo “

\n”;

?>
<?php

error_reporting(E_ALL);
ini_set(‘display_errors’, ‘On’);

$username = “hr”; // Use your username
$password = “welcome”; // and your password
$database = “localhost/orclpdb”; // and the connect string to connect to your database

$query = “select * from dual”;

$c = oci_connect($username, $password, $database);
if (!$c) {
$m = oci_error();
trigger_error(‘Could not connect to database: ‘. $m[‘message’], E_USER_ERROR);
}

$s = oci_parse($c, $query);
if (!$s) {
$m = oci_error($c);
trigger_error(‘Could not parse statement: ‘. $m[‘message’], E_USER_ERROR);
}
$r = oci_execute($s);
if (!$r) {
$m = oci_error($s);
trigger_error(‘Could not execute statement: ‘. $m[‘message’], E_USER_ERROR);
}

echo “\n”;
$ncols = oci_num_fields($s);
echo “\n”;
for ($i = 1; $i <= $ncols; ++$i) {
$colname = oci_field_name($s, $i);
echo ” \n”;
}
echo “\n”;

while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
echo “\n”;
foreach ($row as $item) {
echo “\n”;
}
echo “\n”;
}
echo “

“.htmlspecialchars($colname,ENT_QUOTES|ENT_SUBSTITUTE).”
“;
echo $item!==null?htmlspecialchars($item, ENT_QUOTES|ENT_SUBSTITUTE):” “;
echo “

\n”;

?>
You need to edit this file and set your database username, password and connect string. If you are using Oracle Database XE, then the connect string should be “localhost/XE”. The SQL query can also be changed. Currently it queries the special DUAL table, which every user has.
Load the test program in a browser using http://localhost/test.php. The output will be the single value “X” in the column called “DUMMY”.

You can read more about PHP OCI8 in the PHP manual, and in the free Underground PHP and Oracle Manual from Oracle.

Enjoy your coding with OCI8!

How to modify Maven M2_REPO in Eclipse

Solution

To modify the M2_REPO value, you need to change it at Eclipse’s Maven configuration page. Select Windows -> Preferences -> Maven -> User Settings.

Once above value is updated, it will update the M2_REPO classpath variable automatically.

Now, Select Windows -> Preferences->Java->Build Path->Classpath Variables

Done!