ClamAV exclude on some signature does not work

I use ClamAV with 3rd party signature. So, in order to exclude some virus signature from scanning, I followed the official documentation to add a new .ign2 file like below:

cd /usr/local/share/clamav/
touch whitelist.ign2
chmod 644 whitelist.ign2

When doing the scan I got a false positive signature like this:

/mysql/mysql_backups-02-08-2020_04-30-01/databasedbs.sql.gz: YARA.eval_post.UNOFFICIAL FOUND

So, I included the signature like this in the whitelist.ign2. Here are some of other exclude signatures:

$ cat /usr/local/share/clamav/whitelist.ign2
{HEX}Malware.Expert.generic.eval.post.2
{HEX}php.malware.magento.594
{HEX}Malware.Expert.malware.url.hastebin.com.0
{multi}Malware.Expert.wget.curl.lwp-download.exec.system.signature
YARA.php_malware_hexinject
YARA.shankar_php_php
YARA.Safe0ver_Shell__Safe_Mod_Bypass_By_Evilc0der_php
{HEX}Malware.Expert.generic.eval.gzinflate.base64.9
{HEX}Malware.Expert.generic.malware.127
YARA.r57shell_php_php
YARA.eval_post

From my tests, some signature are excluded like

{HEX}php.malware.magento.594, {HEX}Malware.Expert.generic.eval.post.2

but some signatures are not excluded and still found by clamav eventhough I have included in the excluded list example:

YARA.eval_post, YARA.r57shell_php_php

Anyone experience this problem ? What do you do to solve this.

How to sell signature links

Advertising

y u no do it?

Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

Starts at just $1 per CPM or $0.10 per CPC.

p2sh – How can I recover last word of BIP-32/39 mnemonic copay second signature multisig wallet

I’ve got a multisig 2of2 wallet in copay.

I’ve one wallet correct but have lost second wallet and only have 11 of the 12 words of the seed.I’m pretty sure I miss the last one.
I’ve got some of the first created adresses and trying to recover using btcrecover but throws an error:

The entered address is invalid (not a Bitcoin P2PKH address; verson byte is 0x05)

Copay uses P2SH addresses for multisig addresses and I don’t know hot to proceed.

Any hints?

C binary search signature – Code Review Stack Exchange

This is a question basically just on the signature of the function. I want to implement a binary search in c. A quick signature will be:

typedef int (*cmp_t)(void *a, void *b, void *ctx);

void *bsearch(void *arr, size_t arr_size, size_t elem_size, cmp_t cmp, void *ctx);

Now, I don’t want to accidentally change the array, so I will want to change it to const void *arr. But this will require me to const-cast the pointer when I return it, which is no fun – the caller might pass a const array, and I will const cast it away 😉

I’m really not sure what is the correct way to do this…

encryption – How should I sign a CSR using a signature created in HSM, in C# .NET Core?

I’m exhausted after looking for an answer for 3 days. I don’t know if my suggested flow is wrong or my Google skills have really deteriorated.

My API needs to create a valid certificate from a CSR it received, by signing it with a private key that exists ONLY inside an HSM-like service (Azure KeyVault), which unfortunately doesn’t offer Certificate Authority functions BUT does offer signing data with a key that exists there. My CA certificate’s private key is stored in the HSM. I’m using ECDSA.

My suggested flow:

  1. Client generates Key Pair + CSR and sends CSR to API
  2. API creates a certificate from the CSR
  3. API asks HSM to sign the CSR data and receives back a signature
  4. API appends the signature to the certificate and returns a signed (and including CA in chain) certificate to the Client

Flow

I’m using C# .NET Core and would like to keep it cross-platform (as it runs in Linux containers), so I have to keep it as native as possible or using Bouncy Castle (which I’m still not sure if runs in Linux .NET Core).

I really appreciate your help!

Any idea why Bitcoin Core signature is untrusted?

It’s suppose to be a trusted signature, right?. I’m downloading Bitcoin Core from bitcoin.org

gpg --import laanwj-releases.asc
gpg: key 90C8019E36C2E964: 51 firmas no comprobadas por falta de claves
gpg: clave 90C8019E36C2E964: "Wladimir J. van der Laan (Bitcoin Core binary release signing key) <laanwj@gmail.com>" sin cambios
gpg: Cantidad total procesada: 1
gpg:              sin cambios: 1

sha256sum --check SHA256SUMS.asc
sha256sum: bitcoin-0.20.0-aarch64-linux-gnu.tar.gz: No such file or directory
bitcoin-0.20.0-aarch64-linux-gnu.tar.gz: FAILED open or read
sha256sum: bitcoin-0.20.0-arm-linux-gnueabihf.tar.gz: No such file or directory
bitcoin-0.20.0-arm-linux-gnueabihf.tar.gz: FAILED open or read
sha256sum: bitcoin-0.20.0-osx64.tar.gz: No such file or directory
bitcoin-0.20.0-osx64.tar.gz: FAILED open or read
sha256sum: bitcoin-0.20.0-osx.dmg: No such file or directory
bitcoin-0.20.0-osx.dmg: FAILED open or read
sha256sum: bitcoin-0.20.0-riscv64-linux-gnu.tar.gz: No such file or directory
bitcoin-0.20.0-riscv64-linux-gnu.tar.gz: FAILED open or read
sha256sum: bitcoin-0.20.0.tar.gz: No such file or directory
bitcoin-0.20.0.tar.gz: FAILED open or read
sha256sum: bitcoin-0.20.0-win64-setup.exe: No such file or directory
bitcoin-0.20.0-win64-setup.exe: FAILED open or read
sha256sum: bitcoin-0.20.0-win64.zip: No such file or directory
bitcoin-0.20.0-win64.zip: FAILED open or read
sha256sum: bitcoin-0.20.0-x86_64-linux-gnu.tar.gz: No such file or directory
bitcoin-0.20.0-x86_64-linux-gnu.tar.gz: FAILED open or read
sha256sum: WARNING: 20 lines are improperly formatted
sha256sum: WARNING: 9 listed files could not be read

gpg --verify SHA256SUMS.asc
gpg: Firmado el mié  3 jun 10:59:52 2020 WEST
gpg:                usando RSA clave 90C8019E36C2E964
gpg: Firma correcta de "Wladimir J. van der Laan (Bitcoin Core binary release signing key) <laanwj@gmail.com>" (desconocido)
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 01EA 5486 DE18 A882 D4C2  6845 90C8 019E 36C2 E964

signature – How to verify a signed message by bitcoin core?

I want to verify, in Java, a signature produced with bitcoin core’s signmessagewithprivkey (equivalent to the verifymessage). I noticed a bitcoinj method similar to the bitcoin core’s verifymessage – org.bitcoinj.core.ECKey.verify. What follows is my implementation attempt and its test.

For testing I will generate a signature and check it in bitcoin core:

>bitcoin-cli signmessagewithprivkey $(bitcoin-cli dumpprivkey 1CwKH9PQPkFPjQagEv483FUM5ngk57L3Pp) ""
H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic=
> bitcoin-cli verifymessage "1CwKH9PQPkFPjQagEv483FUM5ngk57L3Pp" "H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic=" ""
true

So, signing an empty message with the RPC using the address 1CwKH9PQPkFPjQagEv483FUM5ngk57L3Pp (public key: 021c3be5fb7820c56d881ea2d02a906d87540ec8888bbe819b7abd2e39f6f6e512), produces the signature H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic=.

My Java implementation attempt:

import org.apache.commons.codec.binary.Hex;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Sha256Hash;
import java.math.BigInteger;
import java.util.Base64;

public class Notebook {

    public static BigInteger() ParseSig(byte() sigBytes, int sigOff) {

        BigInteger r = new BigInteger( 1 ,sigBytes, sigOff, 32);
        BigInteger s = new BigInteger( 1, sigBytes, sigOff + 32, 32);
        return new BigInteger() { r, s };
    }

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

        // Signature
        String signatureString = "H2wp/+5N2+OQwP6a5GFRbt8S+EfML1Szx4uhWPfiO0e/QcY2rZQOkLOR+unknNl4NgDWBacRRXOLjr+m53V0xic=";
        byte() signatureBytes = Base64.getDecoder().decode(signatureString);
        BigInteger() signatureRandS = ParseSig(signatureBytes, 1);
        ECKey.ECDSASignature signature = new ECKey.ECDSASignature(signatureRandS(0), signatureRandS(1));

        // Public key
        String pubKeyString = "021c3be5fb7820c56d881ea2d02a906d87540ec8888bbe819b7abd2e39f6f6e512";
        byte() decodedPubKeyString = Hex.decodeHex(pubKeyString.toCharArray());
        ECKey publicKey = ECKey.fromPublicOnly(decodedPubKeyString);

        // Message
        String message = "Bitcoin Signed Message:n";
        Sha256Hash messageHash = Sha256Hash.of(message.getBytes());
        Sha256Hash messageDoubleHash = Sha256Hash.of(messageHash.getBytes());

        // Test
        boolean result = publicKey.verify(messageDoubleHash, signature);
        System.out.println("Result: " + result);
    }
}

Notice that I used the salt Bitcoin Signed Message:n before hashing the message – this is done by signmessagewithprivkey as shown here and here. The problem is the above implementation doesn’t pass my test and I don’t know why…

EDIT:

Thanks to Septem151 I was able to fix this. The code passes the test, if the message section is replaced with:

        // Message
        String message = "Bitcoin Signed Message:n";
        byte() messageBytesEncoded = new byte(message.getBytes().length + 2);
        messageBytesEncoded(0) = 0x18;
        messageBytesEncoded(messageBytesEncoded.length - 1) = 0x00;
        for(int i=1; i <= message.getBytes().length; i++) messageBytesEncoded(i) = message.getBytes()(i-1);

        Sha256Hash messageHash = Sha256Hash.of(messageBytesEncoded);
        Sha256Hash messageDoubleHash = Sha256Hash.of(messageHash.getBytes());

multi signature – Why do the xpubs from electrum and trezor not match when creating a multisig wallet?

For a little background, I am trying to set up a 2-of-3 multisig wallet with 2 trezors and a coldcard. I am trying to verify that my setup is correct before putting any meaningful amount of money in there, but I am finding that the master pubkeys for the trezors are not matching my expectation.

When creating a standard p2wsh wallet in electrum using a trezor, the default derivation path is m/84'/0'/0'. Immediately after choosing the script type and derivation path electrum displays the master public key. To ensure electrum is using the correct master public key I ran the following command: trezorctl get-public-node -n "m/84'/0'/0'" -t segwit. Sure enough, the master public keys displayed by electrum and trezorctl matched.

However, when trying to do the same verification when creating a multisig wallet, the xpubs do not match. Electrum defaults to the derivation path of m/48'/0'/0'/2' for native segwit multisig wallets. Running trezorctl get-public-node "m/48'/0'/0'/2'" -t segwit outputs a different master public key than what is displayed in electrum. Is this a bug in electrum or is there a reason for the discrepancy? I think that I am misunderstanding something because even though these master public keys don’t match, electrum is able to sign and broadcast valid transactions using the trezor as one of the cosigners.

signature – Do you sign only the previous output of transaction?

The sighash type conditions what is part of the digest which is eventually signed for the transaction to be valid.

Some sighash types allow to either include (commit to) part –or none– of the outputs of the transaction in the digest. Using these far less common sighash types introduce some malleability for a transaction, which usually allow more flexibility when different parties create a single transaction.
You almost always want to use SIGHASH_ALL and you anyway should append a SIGHASH_ALL signature to an input before broadcasting a transaction.

Regarding your question and to sum up, you always sign the current transaction and append this signature to the witness or the scriptSig. This signature can be conditioned using different sighash types.

For reference, you can see the wiki page on OP_CHECKSIG (it only covers the legacy transaction format, though).

multi signature – How do Bitcoin balances work when an address is controlled by multiple parties together?

Bitcoin balances conceptually are not like bank account balances, but more akin to banknotes: uniquely identifiable, good for a specific amount, and can only be spent in full. The “account balance” shown by your wallet is simply the sum of funds that the wallet knows how to spend. In the case of your multisig example, if user1, user2, and user3 each have their own wallet but each wallet keeps tracks of the multisig unspent transaction output (utxo) as its own, they would each see it as part of their balance.

Basically, it’s up to the users to decide how to interpret the spendability of their shared funds. The network would enforce that they would only be able to spend the UTXO once in total, though. Alternatively, it’s possible that they share one “watch-only” wallet to track the balance, but each hold their own separate key. In that case this shared watch-only wallet would track the balance only once, but they’d each hold their own key independently.

So, concretely, the users’ balances after the transaction from user4 would be:

user1, pubkey1, 1.1 BTC
user2, pubkey2, 1.2 BTC
user3, pubkey3, 1.3 BTC
user4, pubkey4, 1.0 BTC
{user1,user2,user3}, 2-of-{pk1,pk2,pk3}, 0.4 BTC

Where the last UTXO is controlled by the multi-party address as described and has different spending properties than the individual balances of the the users.