1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| import org.jsoup.Connection; import org.jsoup.Jsoup;
import java.util.Map;
public class FuckWebLogic { public static void main(String[] args) { try { String SERVER = "http://127.0.0.1:7001/console";
Connection connection = Jsoup.connect(SERVER + "/j_security_check") .method(Connection.Method.POST) .data("j_username", "username") .data("j_password", "password") .followRedirects(false);
Connection.Response response = connection.execute(); int statusCode = response.statusCode(); switch (statusCode) { case 200: System.out.println("login err"); break; case 302: System.out.println("login ok");
Map<String, String> cookies = response.cookies(); System.out.println("Cookie -> " + cookies);
String token = connection.url(SERVER + "/console.portal") .method(Connection.Method.GET) .cookies(cookies) .followRedirects(true) .execute() .parse() .select("input[name=ChangeManagerPortletfrsc]").val();
System.out.println("Token -> " + token);
cookies = response.cookies(); System.out.println("new Cookie -> " + cookies);
response = connection.url(SERVER + "/console.portal") .method(Connection.Method.POST) .data("ChangeManagerPortlet_actionOverride", "/StopEditAction") .data("ChangeManagerPortletfrsc", token) .cookies(cookies) .execute();
System.out.println(response.body().contains("dmz") ? "ok" : "err"); break; } } catch (Exception e) { e.printStackTrace(); } } }
|