Page MenuHomeSoftware Heritage
Paste P1519

gpgsig spoof
ActivePublic

Authored by vlorentz on Nov 2 2022, 8:11 AM.
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dulwich.repo
>>> r = dulwich.repo.Repo(".")
>>> c = r[b"ea6508ced2656533e5857c2e7a7086871c93e3fc"]
>>> c
<Commit b'ea6508ced2656533e5857c2e7a7086871c93e3fc'>
>>> c.as_raw_string()
b'tree 9a9e95e922879815091d6251223366061856cdb0\nparent f46aabf0e0b35ad035ace79dae1946f0d9ec8599\nauthor Valentin Lorentz <vlorentz@softwareheritage.org> 1667372231 +0100\ncommitter Valentin Lorentz <vlorentz@softwareheritage.org> 1667372231 +0100\ngpgsig -----BEGIN PGP SIGNATURE-----\n \n iQGzBAABCgAdFiEEuXMlN3J2MA2cYldnUo6lDNxH4YEFAmNiFMcACgkQUo6lDNxH\n 4YE3LQv9FbmKMek9G74+HRGT2vqyEuVBzUhEQkjeHxAPoawY/sikYnMytentQ2SB\n K47aCBsPkKfHPxoo+jEXNUpljhhUbvA8hBukPklElU6UXrb+osuxHdKdQV+JGVRw\n /QIFS2H4Uuq+AH7qd1XVluEF0m/F2enp4TCXZEOqzuitTRGjeZhQe17QfYA9O3pS\n T8U/5lAhB/F/kQnz/w6kocJzuckTXBB/mVYcpNjsayfadlNCcwksUAz9w+nWYqFP\n rVta9dEa0ymNN30oiPmL1hzuWrOXGqec/ZRayX3z+rkwkV8vWjZeG3wLZGIbtInH\n tza5D6eVmfmxHD+u8CkrMlkTMInTBTAVKB2CDE4CysiqguaLQJvblWWlYgELxkOn\n fl6HGben9k70gk+YjK2ag4zKurAdzuNwUXDJcU0UvC9eIE4s9xgB/Vmul4yjx+2a\n oPMEdTPeInT2vvJ8+sT49bQb3HCekduQ9qywQmlvhjZupEZ65z/hj106rMtij/rQ\n ViWknCH9\n =bu71\n -----END PGP SIGNATURE-----\n\n1.1\n'
>>> import dulwich.objects
>>> c2 = dulwich.objects.Commit()
>>> c2.message = "1.2"
>>> c2.tree = b"4b825dc642cb6eb9a060e54bf8d69288fbee4904"
>>> import time
>>> c2.commit_time = c2.author_time = int(time.time())
>>> c2.commit_timezone = c2.author_timezone = dulwich.objects.parse_timezone(b'+0200')[0]
>>> c2.author = c2.committer = b"Valentin Lorentz"
>>> c2.message = b"1.2"
>>> c2.parents = (c.id,)
>>> c2.gpgsig = c.gpgsig
>>> c2.as_raw_string()
b'tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\nparent ea6508ced2656533e5857c2e7a7086871c93e3fc\nauthor Valentin Lorentz 1667372567 +0200\ncommitter Valentin Lorentz 1667372567 +0200\ngpgsig -----BEGIN PGP SIGNATURE-----\n \n iQGzBAABCgAdFiEEuXMlN3J2MA2cYldnUo6lDNxH4YEFAmNiFMcACgkQUo6lDNxH\n 4YE3LQv9FbmKMek9G74+HRGT2vqyEuVBzUhEQkjeHxAPoawY/sikYnMytentQ2SB\n K47aCBsPkKfHPxoo+jEXNUpljhhUbvA8hBukPklElU6UXrb+osuxHdKdQV+JGVRw\n /QIFS2H4Uuq+AH7qd1XVluEF0m/F2enp4TCXZEOqzuitTRGjeZhQe17QfYA9O3pS\n T8U/5lAhB/F/kQnz/w6kocJzuckTXBB/mVYcpNjsayfadlNCcwksUAz9w+nWYqFP\n rVta9dEa0ymNN30oiPmL1hzuWrOXGqec/ZRayX3z+rkwkV8vWjZeG3wLZGIbtInH\n tza5D6eVmfmxHD+u8CkrMlkTMInTBTAVKB2CDE4CysiqguaLQJvblWWlYgELxkOn\n fl6HGben9k70gk+YjK2ag4zKurAdzuNwUXDJcU0UvC9eIE4s9xgB/Vmul4yjx+2a\n oPMEdTPeInT2vvJ8+sT49bQb3HCekduQ9qywQmlvhjZupEZ65z/hj106rMtij/rQ\n ViWknCH9\n =bu71\n -----END PGP SIGNATURE-----\n\n1.2'
>>> c2.id
b'c16722e21d9063f470ddc97d673fa222e7c5af3d'
>>> r.refs[b"refs/heads/my_succession"] = c2.id
>>> r.object_store.add_object(c2)