Skip to content

Instantly share code, notes, and snippets.

public class MachineProtocolSignatureVerifier {
public static void main(String[] args) throws Exception {
String toVerify = FileUtils.readFileToString(new File("C:\\Users\\user\\Downloads\\010300076\\010300076.csv"));
String signed = "<<base64 from p7s file>>";
byte[] signedByte = Base64.getDecoder().decode(signed);
Security.addProvider(new BouncyCastleProvider());
CMSSignedData cms = new CMSSignedData(new CMSProcessableByteArray(toVerify.getBytes()), signedByte);
31.13.71.0/24 816 1
179.60.192.0/22 930 2
102.132.99.0/24 17 11
129.134.29.0/24 5751 473
31.13.84.0/24 747 1
157.240.14.0/24 739 1
157.240.226.0/24 57 5
129.134.0.0/17 916 2
102.132.96.0/20 910 2
173.252.64.0/19 911 2
public static void main(String[] args) throws Exception {
String prefixes = IOUtils.toString(new URL("https://stat.ripe.net/data/announced-prefixes/data.json?resource=AS32934").openStream());
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(prefixes);
for (JsonNode prefixNode : root.get("data").get("prefixes")) {
try {
String prefix = prefixNode.get("prefix").asText();
// skip IPv6
if (!prefix.contains(":")) {
String updates = IOUtils.toString(new URL("https://stat.ripe.net/data/bgp-updates/data.json?resource=" + prefix).openStream());
package com.yourcomany.util.net;
import org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorFactory;
import org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorSupport;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import java.security.cert.Certificate;
package elections;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.IntStream;
apiVersion: v1
kind: Config
clusters:
- name: logsentinel
cluster:
server: https://api.logsentinel.com/api/k8s/log?trailsApplicationId={applicationId}
# kubeconfig files require a context.
current-context: logsentinel-webhook
package com.yourproject.datastructures;
import java.io.*;
import java.util.*;
import java.util.function.Consumer;
/**
* Disk-backed array list
* @param <E> element type
*/
@Glamdring
Glamdring / ESBulkProcessor.java
Created December 2, 2019 20:12
ElasticSearch Bulk Processor
/**
* A component that takes care of the bulking of elasticsearch indexing requests to accommodate near-real-time indexing
*
* It executes indexing requests when either a time limit or a size limit is reached.
* It avoids blocking the current thread that inserts the records to be indexed.
*/
@Component
public class ESBulkProcessor {
private static final Logger logger = LoggerFactory.getLogger(ESBulkProcessor.class);
@Glamdring
Glamdring / CassandraJSONToCQL.java
Created November 2, 2019 20:17
Convert Cassandra sstabledump JSON to CQL
package com.logsentinel.util.db;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.logsentinel.util.db.dump.Cell;
import com.logsentinel.util.db.dump.Info;
import com.logsentinel.util.db.dump.Row;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
@Glamdring
Glamdring / CertificateTransparenceyVerification.java
Created January 13, 2019 18:36
Java class that allows automated certificate transparency checks
package bg.bozho;
import java.io.FileInputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Security;