Skip to content

Instantly share code, notes, and snippets.

@hkneptune
hkneptune / sha256sum.java
Created October 9, 2023 03:58
SHA256Sum
public static String sha256(File input) throws IOException {
Digest sha256 = new Digest();
sha256.update(Files.readAllBytes(input.toPath()));
StringBuilder buff = new StringBuilder();
for (byte b : sha256.digest()) {
buff.append(String.format("%02x", b & 0xFF));
}
@hkneptune
hkneptune / xml_signing.java
Created October 9, 2023 03:51
Signing XML File Content with p12 File
public static String signXmlContent(String inputFile, String keyStoreFilePath,
String keyStorePassword, String keyStoreAlias) throws Exception {
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(new FileInputStream(keyStoreFilePath), keyStorePassword.toCharArray());
DocumentBuilderFactory buildFactory = DocumentBuilderFactory.newInstance();
buildFactory.setNamespaceAware(true);
Document document = buildFactory.newDocumentBuilder().parse(inputFile);
XMLSignatureFactory xmLSignatureFactory = XMLSignatureFactory.getInstance("DOM",
(Provider) Class.forName("org.jcp.xml.dsig.internal.dom.XMLDSigRI").newInstance());
@hkneptune
hkneptune / centos8.md
Created February 17, 2022 02:00
Upgrade CentOS Linux 8 to CentOS Stream 8

Fix the AppStream Issue

[root@centos8 ~]# yum update
CentOS-8 - AppStream 71 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

As CentOS Linux 8 had reached the End Of Life (EOL) on December 31st, 2021. It means that CentOS 8 will no longer receive development resources from the official CentOS project. To keep your CentOS updated, you may update the mirrors or upgrade to CentOS Stream.

@hkneptune
hkneptune / Discuz4.0.0Crack.md
Created January 1, 2022 05:49
Discuz 4.0.0 (20051001) Crack

Discuz! 4.0.0 (20051001) Crack

  1. Replace the include/validate.class.php file
  2. Create a discuz_license.php file in the root directory
/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
var $jscomp = $jscomp || {};
$jscomp.scope = {};
$jscomp.arrayIteratorImpl = function(array) {
var index = 0;
return function() {
@hkneptune
hkneptune / jquery-script.js
Created September 29, 2020 10:00
jQuery - Open All URLs In New Tab
jQuery(document).on('click', 'body a', function(e){
e.preventDefault();
var url = jQuery(this).attr('href');
window.open(url, '_blank');
});
@hkneptune
hkneptune / Normalize.java
Last active January 31, 2022 20:21
The utility class to solve the Path Manipulation issue found by the Fortify Static Code Analyzer.
/**
* Path Manipulation (Input Validation and Representation, Data Flow)
*
* **Abstract:**
*
* Attackers are able to control the file system path argument, which allows them to access or
* modify otherwise protected files.
*
* **Explanation:**
*
@hkneptune
hkneptune / maven-resources-plugin.xml
Created May 21, 2020 02:49
Copy External Libraries to War Package
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
@hkneptune
hkneptune / mysql-8-centos-8-in-virtualbox.md
Last active November 9, 2023 04:01
Install MySQL 8 on CentOS 8 in VirtualBox

Install MySQL 8 on CentOS 8 in VirtualBox

** Please use the root user to edit the files and execute the commands unless further notice. **

Prerequisite

  1. Install the latest VirtualBox Platform Package and the VirtualBox Extension Pack (Oracle_VM_VirtualBox_Extension_Pack-VERSION.vbox-extpack).
  2. Download the latest VirtualBox Guest Additions (VBoxGuestAdditions_VERSION.iso).
  3. Download the latest CentOS Linux release 8.
  4. Create a new virtual machine and install the CentOS to the virtual machine. During the CentOS installation, select Workstation as Base Environment, select Container Management, Development Tools and Graphical Administration Tools as Additional software for Selected Environment. Use http://mirror.centos.org/centos/8/BaseOS/x86_64/os/ as the installation source.
@hkneptune
hkneptune / oracle-db-19c-centos-8-in-virtualbox.md
Last active March 18, 2024 19:44
Install Oracle Database 19c on CentOS 8 in VirtualBox

Install Oracle Database 19c on CentOS 8 in VirtualBox

** Please use the root user to edit the files and execute the commands unless further notice. **

Prerequisite

  1. Install the latest VirtualBox Platform Package and the VirtualBox Extension Pack (Oracle_VM_VirtualBox_Extension_Pack-VERSION.vbox-extpack).
  2. Download the latest VirtualBox Guest Additions (VBoxGuestAdditions_VERSION.iso).
  3. Download the latest CentOS Stream 8.
  4. Create a new virtual machine and install the CentOS to the virtual machine. During the CentOS installation, select Workstation as Base Environment, select Container Management, Development Tools and Graphical Administration Tools as Additional software for Selected Environment. Use http://mirror.centos.org/centos/8/BaseOS/x86_64/os/ as the installation source.