
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
proxy-git.cwkhome.fun/gabstv/go-bsdiff
Advanced tools
Pure Go implementation of bsdiff 4.
bsdiff and bspatch are tools for building and applying patches to binary files. By using suffix sorting (specifically, Larsson and Sadakane's qsufsort) and taking advantage of how executable files change.
The package can be used as a library (pkg/bsdiff pkg/bspatch) or as a cli program (cmd/bsdiff cmd/bspatch).
package main
import (
"fmt"
"bytes"
"github.com/gabstv/go-bsdiff/pkg/bsdiff"
"github.com/gabstv/go-bsdiff/pkg/bspatch"
)
func main(){
// example files
oldfile := []byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff}
newfile := []byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, 0xff, 0xfe, 0xfe}
// generate a BSDIFF4 patch
patch, err := bsdiff.Bytes(oldfile, newfile)
if err != nil {
panic(err)
}
fmt.Println(patch)
// Apply a BSDIFF4 patch
newfile2, err := bspatch.Bytes(oldfile, patch)
if err != nil {
panic(err)
}
if !bytes.Equal(newfile, newfile2) {
panic()
}
}
package main
import (
"fmt"
"bytes"
"github.com/gabstv/go-bsdiff/pkg/bsdiff"
"github.com/gabstv/go-bsdiff/pkg/bspatch"
)
func main(){
oldrdr := bytes.NewReader([]byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff})
newrdr := bytes.NewReader([]byte{0xfa, 0xdd, 0x00, 0x00, 0x00, 0xee, 0xee, 0x00, 0x00, 0xff, 0xfe, 0xfe})
patch := new(bytes.Buffer)
// generate a BSDIFF4 patch
if err := bsdiff.Reader(oldrdr, newrdr, patch); err != nil {
panic(err)
}
newpatchedf := new(bytes.Buffer)
oldrdr.Seek(0, 0)
// Apply a BSDIFF4 patch
if err := bspatch.Reader(oldrdr, newpatchedf, patch); err != nil {
panic(err)
}
fmt.Println(newpatchedf.Bytes())
}
go get -u -v github.com/gabstv/go-bsdiff/cmd/...
bsdiff oldfile newfile patch
bspatch oldfile newfile2 patch
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.