Solved

Convert $_GET $tring to $_POST $tring?

Posted on 2004-08-04
9
1,274 Views
Last Modified: 2012-08-14
I have an java app that will send a url sting (domain.com/login.php?user=username&pass=password&etc...) to automaticly login to one site.  The other site only looks at $_Post[user] to get the login info.  I do not want to change the second website login method but i do want to login.  

Q: Is there a way I could make a script to take my url $tring [$_GET] and turn it into a post string [$_POST]?

0
Comment
Question by:greyhair
9 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11721291
Use $_REQUEST['name']

Regards,
${Zyloch}  
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 84 total points
ID: 11721385
you really should not send passwords in the url query string, can you not set up your java app to send the data via post
0
 
LVL 25

Assisted Solution

by:Squinky
Squinky earned 83 total points
ID: 11721509
Using $_REQUEST would require him to change the code on the receiving site, which he said he can't do.

You could write a proxy that converts an HTTP GET to a POST, accepting the GET request and generating a new POST request using CURL, then passing the results back to the original requester. Roughly like this:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.postdomain.com/login.php'); //Set to your target URL
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_SERVER['QUERY_STRING']);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec($ch);
curl_close($ch);
?>

The curl_exec will just dump whatever comes back from this POST request to the original GET requester. You might need to a be a little more careful with what you pass into CURLOPT_POSTFIELDS, but the principle should hold together. You may also need/want to pass through various other info from the original requester (in the same way as I have with user agent). Also bear in mind that this route will make it look like your server rather than the requester is the real requester, which may mean that the log works, but only for your server's IP address, depending on how they have their login script set up.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 18

Assisted Solution

by:arantius
arantius earned 83 total points
ID: 11743466
Point your java app to this PHP page, and this form's action to the real app:


<html>
<head>
<title>whatever</title>
</head>
<body>

<form method="post" action="http://......../">
<?
foreach ($_GET as $key => $value) {
  printf("<input type=\"hidden\" name=\"%s\" value=\"%s\" />", $key, $value);
}
?>
<button type="submit">Continue login...</button>
</form>
</body>
</html>
0
 

Expert Comment

by:savtrad
ID: 23359211
You can use Java Script to submit a form with Post values activated by a hyper link. This will give you a hyper link appearance which will submit form vaues using the post menthod.
Place this java script between your head tags. Use hidden input form fields for additioal post values sent by the java script activated submit action.

<html>

<head>

<title>Title</title>

<script language="JavaScript" type="text/javascript">

<!--

function submitlink ( postvalue )

{

  document.linkform.area_session.value = postvalue ;

  document.linkform.submit() ;

}

-->

</script>
 

</head>

<body>

<form name="linkform" action="/index.php" method="POST" >

    <input type="hidden" name="area_change" value="Change" />

    <input type="hidden" name="area_session" />

    <a href="javascript:submitlink('Members_Area')">Members Area</a><br />

    <a href="javascript:submitlink('Free_Area')">Free Area</a><br />

                        </form>

</body>

</html>

Open in new window

0
 
LVL 36

Expert Comment

by:Zyloch
ID: 23359319
Wow, this is so old. Back in the times when I was still young and naive =)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now