0

I have a fun challenge. I have to send the password "flubergump" to a page on the net (php script).

I wrote this common code:

try {

    URL url = new URL(A);
    URLConnection con = url.openConnection();
    con.setDoOutput(true);

    OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream());
    F = URLEncoder.encode(F, "UTF-8");
    writer.write(F);
    System.out.println(F);
    String line;

    DataInputStream in = new DataInputStream (con.getInputStream ());

    while ((line = in.readLine()) != null) {
        G=G + line;
    }
    textarea.setText(G);
    writer.close();
    in.close();

and tried sending every version of password = flubergump!

Sending this HTML would work:

<form method="post" action="http://www.hackthis.co.uk/levels/i2.php">
<input type="hidden" name="password" value="flubergump">
</form>

But I wanted to make a "post variables" tool, simply in the name of practice. Can you help by telling me why I'm not getting any success. I tried writing my own PHP scripts and I'm still having no luck. I've researched this topic to death, and one would get the impression that this code is supposed to work.

jszobody
  • 28,495
  • 6
  • 61
  • 72
Jethro Devøn
  • 31
  • 1
  • 8
  • "still getting no luck" LOL you can see im not going to get anywhere if I think luck is going to help me code :P – Jethro Devøn Apr 24 '13 at 22:30
  • I cant use "setRequestMethod (POST)" my compiler thinks it doesn't exist, is this a thing? – Jethro Devøn Apr 24 '13 at 22:33
  • You say it's php-code but it looks like java? – bestprogrammerintheworld Apr 24 '13 at 22:33
  • OH no I have forgot to state that its java:/ brain must be really frazzled sry – Jethro Devøn Apr 24 '13 at 22:36
  • But then of course it won't work with your form with action="l2.php" – bestprogrammerintheworld Apr 24 '13 at 22:37
  • "Setting the URLConnection#setDoOutput() to true means that you're about to write request data to the request body" – Jethro Devøn Apr 24 '13 at 22:45
  • What is the value of F? (I think it should be `password=flubergump`) – flup Apr 24 '13 at 22:49
  • @JethroDevøn - I don't understand the problem. You can't mix different languages in which manner you want. A php script would look like and echo out "flubergump" to the browser. – bestprogrammerintheworld Apr 24 '13 at 23:00
  • If your java code is supposed to send a POST request, maybe the first answer of [this question](http://stackoverflow.com/questions/4205980/java-sending-http-parameters-via-post-method-easily) should get you started. – martin Apr 24 '13 at 23:07
  • yes thats right flup, Im not sure what you mean martin, I have written a java code that sends "password=flubergump" to the php scripts in URL, am I in the PHP part od stack overflow by mistake and not the java one? im so confused – Jethro Devøn Apr 24 '13 at 23:17
  • oh "this question" was a link, I thought you were being cryptic – Jethro Devøn Apr 24 '13 at 23:27
  • no these dont help, I have copied what works for other people and still not got the desired result (I have looked for the answer hard and only found people using identicle code to me and having great success, what is it that "bestprogrammerintheworld"is getting at, can i not post to these guys??) – Jethro Devøn Apr 24 '13 at 23:30

0 Answers0