public static synchronized void loadJAR(File jar) throws ClassNotFoundException { try { URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader(); URL url = jar.toURI().toURL(); if (Arrays.asList(loader.getURLs()).contains(url)) return; Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { java.net.URL.class }); method.setAccessible(true); method.invoke(loader, new Object[] { url }); } catch (final ReflectiveOperationException e) { throw new ClassFormatError(e.getMessage()); } catch (final java.net.MalformedURLException e) { throw new ClassNotFoundException(e.getMessage()); } }
base_facebook.php
, facebook.php
, and fb_ca_chain_bundle.crt
in their corresponding paths and included as required.<? abstract class IdentityProviderInterface{ public $name; public function __construct($name){ $this->name=$name; } public function getName(){ return $this->name; } abstract public function getLabel(); abstract public function getIconUrl(); abstract public function getLink(); abstract public function login(); abstract public function logout(); public function getUser(){ return @$_SESSION['contact']['id']; } } class OAuthFB extends IdentityProviderInterface{ function __construct(){ parent::__construct('facebook'); //$this->data=array('icon'=>'//facebook.com/favicon.ico','label'=>'Facebook','protocol'=>'OAuth-FB', 'login'=>'https://www.facebook.com/dialog/oauth','logout'=>'http://www.facebook.com/logout.php'); } public function getLabel(){ return 'Facebook'; } public function getIconUrl(){ return '//facebook.com/favicon.ico'; } public function getLink(){ return "?FederatedIdentityProvider=facebook"; } public function login(){ require_once("$_SESSION[common_system_folder]/OAuth-FB/facebook.php"); $facebook=new Facebook(array('appId'=>'*****************','secret'=>'*****************')); $user=$facebook->getUser(); if($user){ try{ $userProfile= $facebook->api('/me');// the "me" represents the customer's profile, as you query the FB on the customer's behalf $_SESSION['contact']['provider']=@$_GET['FederatedIdentityProvider']; $_SESSION['contact']['name']=@$userProfile['name']; $_SESSION['contact']['id']=@$userProfile['username'].'@facebook.com'; return; }catch(Exception $e){ } }?>< ><html xmlns:fb="http://www.facebook.com/2008/fbml"><body><fb:login-button></fb:login-button><div id="fb-root"></div> <script>window.fbAsyncInit=function(){FB.init({appId:'<?php echo $facebook->getAppID()?>',cookie:true,xfbml:true,oauth:true}); FB.Event.subscribe('auth.login',function(response){window.location.reload();}); FB.Event.subscribe('auth.logout',function(response){window.location.reload();});}; (function(){var e=document.createElement('script');e.async=true;e.src=document.location.protocol+'//connect.facebook.net/en_US/all.js';document.getElementById('fb-root').appendChild(e);}()); </script></body></html> <?die; } public function logout(){ require_once("$_SESSION[common_system_folder]/OAuth-FB/facebook.php"); $facebook=new Facebook(array('appId'=>'*****************','secret'=>'*****************')); if(@$facebook->getUser()) header('Location: '.$facebook->getLogoutUrl()); } }?>
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.List; import java.util.Map; import org.postgresql.util.Base64; //import org.apache.commons.io.IOUtils; public class HeadlessBrowser { private List<String> cookie = null; private HttpURLConnection getConnection(String url, String... headers) throws MalformedURLException, IOException { HttpURLConnection connection; connection = (HttpURLConnection) new URL(url).openConnection(); if (cookie != null) for (int i = 0; i < cookie.size(); i++) connection.addRequestProperty("Cookie", cookie.get(i)); if (headers != null) for (String header : headers) { int kvPos = header.indexOf(':'); connection.setRequestProperty(header.substring(0, kvPos), header.substring(kvPos + 1)); } connection.setRequestProperty("User-Agent", "HeadlessBrowser/1402211648 (+http://dragos-matei.sorescu.eu)"); return connection; } public Response get(String url,String...headers) throws IOException { HttpURLConnection connection = getConnection(url,headers); Response response = new Response(connection.getHeaderFields(), connection.getInputStream()); List<String> setCookie = response.headerFields.get("Set-Cookie"); if (setCookie != null) cookie = setCookie; return response; } public Response post(String url, String postBody, String... headers) throws IOException { HttpURLConnection connection = getConnection(url, headers); connection.setDoOutput(true); connection.getOutputStream().write(postBody.getBytes()); Response response; try { response = new Response(connection.getHeaderFields(), connection.getInputStream()); } catch (Throwable t) { response = new Response(connection.getHeaderFields(), connection.getErrorStream()); } List<String> setCookie = response.headerFields.get("Set-Cookie"); if (setCookie != null) cookie = setCookie; return response; } public Response put(String url, String postBody, String... headers) throws IOException { HttpURLConnection connection = getConnection(url, headers); connection.setDoOutput(true); connection.setRequestMethod("PUT"); connection.getOutputStream().write(postBody.getBytes()); Response response; try { response = new Response(connection.getHeaderFields(), connection.getInputStream()); } catch (Throwable t) { response = new Response(connection.getHeaderFields(), connection.getErrorStream()); } List<String> setCookie = response.headerFields.get("Set-Cookie"); if (setCookie != null) cookie = setCookie; return response; } public class Response { public Map<String, List<String>> headerFields; private byte[] body; public Response(Map<String, List<String>> headerFields, InputStream body) throws IOException { this.headerFields = headerFields; ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (body != null) { byte[] dump = new byte[65536]; for (;;) { int length = body.read(dump); if (length < 0) break; baos.write(dump, 0, length); } } this.body = baos.toByteArray(); } public byte[] getBodyBytes() { return this.body; } public String toString() { return new String(this.body); } public String toBase64String() { return Base64.encodeBytes(this.body); // return new String(dms.os.Codec.base64.encode(this.body)); } public String getHeader(String header) { List<String> strings = headerFields.get(header); return (strings == null) ? null : strings.get(0); } } }
<?php
function apiCall($path,$params){
$result=array();
$url='http://crm.sorescu.eu/'.$path;
$opts=array('http'=>array('method'=>'POST','header'=>'Content-type: application/x-www-form-urlencoded','content'=>http_build_query($params)));
$out=file_get_contents($url,false,stream_context_create($opts));
$result['url']=$url;
$result['in']=$params;
$result['out']=json_decode($out,true);
return $result;
}?>
my_file.hta
;throw new RuntimeException(myOldJunkyException)
new RuntimeException().setStackTrace(myNewSyntheticStackTraceIncludingRemoteJunkyLines)
public static int main(String[] args) throws IOException { THROW(new RuntimeException()); return "dummy statement that won't ever be executed, but it's requied to compile the function. The compiler cannot figure out that the THROW will throw an exception... :D".length(); }PS: Don't try it on JVM clones, it might not work at all. Neither on Google's Dalvik...
{domain_controller_machine}
can be found by running Windows echo %logonserver%
, then run tracert {logon_server}
to identify it's full name.{my_ntnet_user in short form}
is my NTNET user without any realm or domain information. <div class='pull-right' onclick='$(this).find("a").toggle()'> <a onclick='for(var k in{request:1,webkit:1,moz:1,ms:1})try{document.documentElement[k+"RequestFullScreen"]();}catch(e){console.log(e)}'><%icon:maximize%></a> <a style='display:none' onclick='for(var k in{exitFulls:1,mozCancelFullS:1,webkitCancelFullS:1})try{document[k+"creen"]();}catch(e){console.log(e)}'><%icon:window%></a> </div>
package dms; import java.util.Hashtable; import javax.naming.Context; import javax.naming.Name; import javax.naming.NamingException; import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; import javax.naming.ldap.LdapName; public class Test { public static void main(String[] args) { try { test(); } catch (NamingException e) { System.out.println(e.getMessage()); } } public static void test() throws NamingException { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://ldap_server.www.company.com:389/o=Users"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "CN=myUserName,CN=Users,DC=ldap_server,DC=www,DC=company,DC=com"); env.put(Context.SECURITY_CREDENTIALS, "********"); DirContext ctx = new InitialDirContext(env); Name name=new LdapName("invalid_name"); Object o=null; ctx.bind(name, o); //Should throw "invalid name exception" } }