äžè¬çã«ãæ»æè ã¯æªæã®ããããã°ã©ã ãäœæããŸããã»ãšãã©ã®å Žåãããã¯é ããæ©ãããŠã€ã«ã¹ã¢ããªã¹ãã®ããªãã¬ãŒãã£ã³ã°ããŒãã«ãã«å°éããããšãäºåã«ç¥ã£ãŠããŸãã ãããŠããã«ãŠã§ã¢ããã®ãã¹ãŠã®æ å ±ã¯äœæè ã«å¯ŸããŠäœ¿çšã§ããŸãã ãªã圌ã¯é ãå¿ èŠããããŸããïŒ ãŸãããŸã第äžã«ãããªãã®æ§æ Œã ãã«ãŠã§ã¢ã§ã¯ãCïŒ\ Users \ Vasiliy Ivanov \ Documents \ Visual Studio 2005 \ profits \ trojan \ Release \ trojan.pdbãªã©ã®æååã«ééããããšããããŸãã 第äºã«ããã«ãŠã§ã¢ã®åæã容æã«ããå€ãã®æ å ±ããããŸãã ãŠã€ã«ã¹äœæè ã®ãã¯ããã¯ã®ããã€ããèŠãŠããããããªã圹ã«ç«ããªãããèŠã€ããŸãããã
圌ããé ããã®ïŒ
ã€ã³ã¿ãŒããããªã³ã¯
Trojan-Downloaderã®ã€ã³ã¹ã¿ã³ã¹ã¯ãäž»ã«1ã€ä»¥äžã®ãªã³ã¯ãä»ããŠä»ã®ãã«ãŠã§ã¢ãããŠã³ããŒã/æŽæ°ããŸãã æããã«ããªã³ã¯ãæ瀺çã«ä¿åãããŠããå ŽåããŠã€ã«ã¹å¯ŸçäŒç€Ÿã®èªååŠçã·ã¹ãã ã¯ãªã³ã¯ãç°¡åã«æœåºããå®æçãªããŠã³ããŒãã®ãªã¹ãã«è¿œå ããŠããããã®ãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ãçŠæ¢ã§ããŸãã Trojan-Downloaderã®æå³ã¯å®å šã«å€±ãããŸãã ä»ã®ã¯ã©ã¹ã®æªæã®ããã¯ã©ã¹ãã¢ãžã¥ãŒã«ã®æ°ããããŒãžã§ã³ãããŠã³ããŒãããããšãäžè¬çã§ãã
ã³ã³ããŒãã³ã
ãã«ãŠã§ã¢ã¯çŸåšãè€éãªãã«ãã³ã³ããŒãã³ãã§ãã 1ã€ã®ã¢ãžã¥ãŒã«ã¯æŽæ°ãæ åœãã2çªç®ã¯ã«ãŒãããããã©ã€ããŒã3çªç®ã¯ãã¹ã¯ãŒãã®åéã4çªç®ã¯ã³ã³ãããŒã«ã»ã³ã¿ãŒããã®ã³ãã³ãã®åä¿¡ãšçµæã®éä¿¡ãæ åœããŸãã äžè¬çã«ãããããã¹ãŠã1ã€ã®ãã€ã³ã¹ããŒã©ãŒãã«ãªããŸãã ãµãŒãããŒãã£ã®ãéçºè ãã®ç¹å¥ãªããã€ã®æšéŠ¬ã§ããå Žåãããã°ãåãäœè ã®å¥ã®ã³ã³ããŒãã³ãã§ããå ŽåããããŸãã URLãšåæ§ã«ãå éšPE-EXEã¢ãžã¥ãŒã«ããã確å®ã«é衚瀺ã«ã§ããªãå ŽåãèªååããŒã«ã«ãã£ãŠç°¡åã«ç Žæ£ããããã¹ãŠã®ãã¡ã€ã«ãèªååæããã³èªåæ€åºã®ããã«éä¿¡ãããŸãã ããã«ãã¢ãžã¥ãŒã«ã®å°ãªããšã1ã€ãæªæã®ãããã®ã§ãããšå€æããå Žåãããã¯å šäœãæåã§åæããå¿ èŠã¯ãªãããã¹ãŠãæ£åžžã«æ€åºãããŸãã
ãã¹ã¯ãŒã
ä¿¡ããããªããããããŸããããæªæã®ãããã¡ã€ã«ã§ã¯ãäœæè ã¯ãã¹ã¯ãŒããæå·åãããããŸãã ãã¡ããããã»ã©é »ç¹ã§ã¯ãããŸããããå®éã¯ããã§ãã ããšãã°ãTrojan-Spyãå€ãã®ã¹ã¯ãªãŒã³ã·ã§ãããæ®ãïŒãŸãã¯è¢«å®³è ã®ã«ã¡ã©ã§ãããªãæ®ãïŒå Žåãäœæè ã«çŽ æãé ä¿¡ããéåžžã®æ¹æ³ã¯FTPã«ã¢ããããŒãããããšã§ãã ãŠã€ã«ã¹äœæè ã¯ãèªã¿åãããã³æžã蟌ã¿ã¢ã¯ã»ã¹æš©ãæã€1ã€ã®ã¢ã«ãŠã³ããäœæããŸãã ãããŠãã ãã圌ã®FTPãããŸããããšãªãããã«ãŠã§ã¢ã³ãŒãã«é©åãããã¹ã¯ãŒããèšå®ããŸãã ãã®çµæãããã«è¿·ã蟌ãã®ã¯èª°ã§ãã§ã¯ãªãããã¹ãŠã®æŠå©åãæ¶å»ããŠäžå¹žãªèè ã«ã¡ã¢ãæ®ãç¹å®ã®ç¬ç«ããç 究è ã§ãã ããã¯ãã³ã³ãã¥ãŒã¿ãŒæ å ±ãžã®éæ³ãªã¢ã¯ã»ã¹ ãã§ãããç¯çœªè ã ãã声æãæžãããã«å®è¡ããªãããšã«æ³šæããŠãã ããã
å¥ã®äŸã¯ãã¡ãŒã«ããã¯ã¹ã®ãã¹ã¯ãŒãã§ãã äœæè ã¯ã被害è ããåéãããã¹ã¯ãŒããèªåã§éä¿¡ããå¿ èŠããããŸãã ãããã圌ã®ã¡ãŒã«ããã¯ã¹ãç»é²ãããŠããã¡ãŒã«ãµãŒãã¹ã¯ãç解ã§ããªã人ã ãžã®æçŽã®éä¿¡ãèš±å¯ãããéä¿¡æã«èªèšŒãå¿ èŠãšããŸãã ãæ·±å»ãªããã«ãŠã§ã¢ãç¹ã«éè¡æ å ±ã®çé£ãçã£ãŠãããã«ãŠã§ã¢ãããã»ã©ééã£ãŠããªãããšã¯æããã§ãã å¯Ÿç §çã«ãä»ã®äººã¯èªåã®ã³ãŒããã¢ããªã¹ãã«ãã£ãŠã¬ãã¥ãŒãããããšãæå³çã«æåŸ ããå ŽåããããŸãã ä»ã§ã¯ã»ãšãã©ãã¹ãŠãèªååãããŠããŸããã10幎åã«èªåã§ãã¡ã€ã«ãåæãããšãã«ããµã³ãã«å ã®ãŠã€ã«ã¹ã¢ããªã¹ãã«ãã®ãããªé åã«åºäŒããŸããããããã¯èª°ã«ãæ€åºãããªããã³ãã§ãããã®ãŸãŸã«ããŠããããã§ãã ãã®ããã«äœãããå¿ èŠã¯ãããŸããã ããããšããã
ç°¡åãªæå·åïŒ
ãããã£ãŠãçµè«ã¯æ¬¡ã®ãšããã§ãããŠã€ã«ã¹äœæè ã¯äœæç©ã®äžã«é ãã¹ããã®ãããããããå®è¡ããããšããŠããŸãã XOR ã ROLãããæäœãšã¯äœããããç解ããŠããããããã䜿çšããŠããŒã¿ãå€æããæ¹æ³ãç解ããŠããå Žå㯠ããã®ã»ã¯ã·ã§ã³å šäœãã¹ãããã§ããŸãã
httpïŒ//secret.urlãšããè¡ããããã³ãŒãå ã§ç®ã§èŠãããªãããã«ããããšããŸãã åæã«ã埩å·åã¢ã«ãŽãªãºã ãšããŒãåãã³ãŒãã«å«ãŸããŸããããã¯ããã®è¡ãå¿ èŠã«ãªãããã§ãã ããããæãç°¡åãªæ¹æ³ã¯æ¬¡ã®ãšããã§ãã
ãªã
ããããã§ãŒã³ã®åœ¢ã®æååãæ³åããŠãã ãã110100001110100 ...åããããå察ã®001011110001011ã«çœ®ãæããŸã...æåå " CHLPâŒâšâšM "ãåŸãããŸãã çŸåšãèçŒã§ã¯ãã®ãããªç·ãèªèã§ããŸããã ãã ããããã°ã©ã ã§å®è¡ã§ããŸãã ãã¡ã€ã«å šäœã«NOTæäœãé©çšããŠã¿ãŸããããæå·åããããã®ã¯åŸ©å·åãããŸãã ãããŠãããã§ã¯ãªããã®ã¯æå·åãããŸãã çµæã®ãã¡ã€ã«ã§ã¯ãURLã¯ãªãŒãã¡ãŒã·ã§ã³ãšç®ã«èŠããŸãã
Xor
å°ãè€éã§ãã æå·åãããšãããã¹ãŠã®ããããå転ããããšã¯ã§ããŸããããããšãã°ã4åããšã«å転ãããããšãã§ããŸãïŒã ãã誰ãæšæž¬ããªãããã«ïŒã ãã®ãããªãããã®å転ã¯ãXORæŒç®ãšãåŒã°ããŸãã AïŒ= XORããŒãæžã蟌ãŸããŸããaã¯å€æããããã€ãã§ã keyã¯ã©ã®ããããå€æŽãããããæžã蟌ãŸããããŒã§ãã
ããã«ãNOTæŒç®ã¯aïŒ= a XOR FFãšåçã§ãã 16é²FFã¯ãã€ããª11111111ã«çãã-åããããå転ããŸãã
埩å·åããã«ã¯ãåãããŒã§ããŒã¿ãå床ãçªããå¿ èŠããããŸãã ãããæ£ç¢ºã«ãªãªãžãã«ã§ããããšã確èªããããã«ãç§ã¯å¥œå¥å¿ã®åŒ·ãèªè èªèº«ã«ææ¡ããŸãã åã®æ¹æ³ãšã¯ç°ãªãããã®æ¹æ³ã§ã¯ãå®è¡æã«ããŒã¿ã埩å·åããå ŽåãããŒãããã°ã©ã ã«ä¿åããå¿ èŠãããããšãå¿ããªãã§ãã ããã ãŸããã¢ããªã¹ãã¯ãæååã解èªããããã«ããŒãæ€çŽ¢/å埩ããå¿ èŠããããŸãã ãã ããå¥ã®æ¹æ³ããããŸãããããã«ã€ããŠã¯ä»¥äžã§è©³ãã説æããŸãã
ãã®ä»ã®æ¹æ³
ä»ã«ã§ããããšïŒ
- ADDæäœãåãã€ãã«é©çšããŸããã€ãŸããç¹å®ã®æ°å€-ããŒãè¿œå ããŸã
- ããŒããã€ããããã€ãã«å€æŽããŸãã ããšãã°ãæåã®ãã€ãã¯ããŒ71ã2çªç®ã®ãã€ãã¯73ã3çªç®ã®ãã€ãã¯75ãªã©ãšãâãã§ãã 次ã«ãããŒãåçŽã«ãœãŒãããããšã¯ã§ããªããªãã2ã€ã®ããŒããœãŒãããå¿ èŠããããããã¯256åé·ããªããŸã
- ããŒã®é·ããå¢ããããšãã§ããŸãã ããšãã°ã4ãã€ãããŒã§ãããããããæåã®DWORDããããšããããããã2çªç®ã®DWORDãªã©ã 次ã«ãããŒãªãã§åŸ©å·åããã«ã¯ã40åã®ãªãã·ã§ã³ã䞊ã¹æ¿ããå¿ èŠããããŸãã ãããŠãããªãïŒãŸãã¯ãã£ã¢ãªã³ã°ããã°ã©ã ïŒãæ¢ããŠããæ å ±ããã¡ã€ã«ã®ã©ãã«ããã®ãæ£ç¢ºã«ããããªãå Žåã¯ãåãã€ãããœãŒãããå¿ èŠããããŸãïŒãã«ãŠã§ã¢ã®ãµã€ãºã¯éåžžæ°çŸãããã€ãã§ãïŒ
- ROL埪ç°ã·ããæäœãåãã€ãã«é©çšã§ããŸãã ãã ãããã€ãæå·åã§ã®ã¿ãããŒã«ããæå¹ãªã®ã¯1ã7ãããã®ã¿ã§ãã 8ãããã®åšæçãªãã€ãã·ããã«ãããåããã€ããåŸãããŸãã
- 2åãå£è«ãããããšãã§ããŸãã ããåºå¡ã¯æååãæå·åããŸããã 圌ã«ã¯ããã§ã¯ååã§ã¯ãªãããã«æãããã圌ã¯åã³åãéµã§åœŒå¥³ãããã³ã«ã·ã«ãããã ããããæ¥ããã®ã¯ãèªåã§æšæž¬ããŠãã ããã
- è¡ã¯éåãã«æžãããšãã§ããŸã
- è¡ã¯ãã€ãåäœã§æžã蟌ãããšãã§ããŸãã ASCIIæåã®å ŽåãUnicodeãååŸããŸãã
- è¡ã¯ã¢ã«ãã¡ãããã®ããã¢ã«ç§»åã§ããŸããã€ãŸããa-> nãb-> oã...ãz-> mã0-> 5ã1-> 6 ...
- 16é²åœ¢åŒã§æåãæžããããªãã¡687474703A2F2F
- æååãã¹ã¿ãã¯ã«é
眮
...
push 'w //ïŒ'
ãptthããæŒã - ãããŠãã®ãããªããš
瀺ããããã¹ãŠã®æ¹æ³ã¯ãæããã«ããã倧ããªé°è¬ã®ããã«çµã¿åãããããšãã§ããŸã:)
ãã³ãŒãïŒ
åé¡ã瀺ããŸãã 1 MBã®ãã¡ã€ã«ããããŸãã å éšã§ã¯ãæªç¥ã®å Žæã§ãäžèšã®ã¡ãœããã®1ã€ãhttpïŒ//ã§å§ãŸãè¡ã§æå·åãããŸãã ããŒã¯äžæã§ãã ãã¡ã€ã«ãåŠçãã壮倧ãªåæãªãã§ãã®è¡ãæœåºããããã°ã©ã ãäœæããå¿ èŠããããŸãã ä»ã®äœããããšãã°å éšãã¡ã€ã«ã®MZ-PEããããŒãæå·åã§ããŸãããæ¡ä»¶ã¯æ¬¡ã®ãšããã§ããæ£ç¢ºã«äœãæ¢ããŠããããããããŸãã ãããŠãæªç¥ã®å Žæã§æå·åãããæªç¥ã®ã¬ãŒãããžãäœãæ¢ãã¹ããããããªã-ããŸããããããä»äºã§ã¯ãªãã
å°ããªäœè«ã LCã¯çŸåšããã®ãããªèªååæã®æ¹æ³ã䜿çšããŠããŸããããã¯ãæå·åã®å¯Ÿè±¡ãšæ¹æ³ãæ°ã«ããŸããã å°ãªããšãéåžžã«å ç¢ãªã¢ã«ãŽãªãºã ïŒèª¬æãããŠãããã®ãšã¯å¯Ÿç §çïŒã ããŒã¿ãããã°ã©ã èªäœã§äœ¿çšãããŠããå Žåã§ããããŒã¿ã¯ååŸãããŸãã 以äžã§ã¯ã説æããæå·åæ¹æ³ããŠã€ã«ã¹äœæè ãä¿è·ãããã¢ããã¥ã¢ã¢ããªã¹ãã«ãšã£ãŠãé£ãããªãããšã瀺ããŸãã å瀺ãªãã æãèŠãŠãã ããã
Xor
NOTæäœãé©çšãããURLãèŠããŠããŸããïŒ ã CHLLPâŒâšâš ãã ãããã®æåãããäžåºŠèŠããšãããã¯åžžã«URLã§ãããšæšæž¬ãããŸãã ãããŠãããŒF0ã§åœé ãããè¡ïŒ " SHDDAâ©ââ "ã§ãã ãŸãã¯ã0Fã®å ŽåïŒ " g {{â5 "ã 2çªç®ãš3çªç®ãæåŸãšæåŸãã2çªç®ã®æåãçããããšã«æ³šæããŠãã ããã 説æãããŠãããã€ãå€æã®ãæçšãªãç¹æ§ã¯ãçãããã€ããçãããã€ãã«å€æããããšã§ãã ããããXORã«ã¯å¥ã®äŸ¿å©ãªããããã£ããããŸã-æäœã¯å¯éã§ãã ã€ãŸãã 'W' = 'h' XORããŒãã
key = 'W' XOR 'h'ã«ãªããŸãã ããã¯ã YTsUKENGã·ãŒã±ã³ã¹ãããå Žåã ããŒïŒ= '' 'XOR' h 'ãæå³ããŸãã 次ã«ã次ã®ããšã確èªããŸã
'C' == 't' XORããŒ
'K' == 'p' XORããŒ
'E' == 'ïŒ' XORããŒ...
ãã®å ŽåãURLãèŠã€ãããããŒãããããŸãã
è¿œå ãã
åæ§ã«ã '' '=' h '+ keyã®å Žåã key =' ''-'h'ã«ãªããŸãã ãããŠãæ®ãã®URLãæ¬åœã«URLã§ããããšã確èªããŸãã
ããããæ»æè ãããŒããã€ããããã€ãã«çŽç·çã«å€æŽãããã©ããªãã§ããããïŒ
'Th' = 'h' +ããŒ
'Ts' = 't' +ïŒããŒ+ dïŒ
'Y' = 't' +ïŒããŒ+ 2dïŒ
'K' = 'p' +ïŒããŒ+ 3dïŒ...
ãã¹ãŠåãïŒ
ããŒ= '' '-' h '
ããŒ+ d = 'C'-'t'
äœæè ã4ãã€ãããŒã䜿çšããå ŽåïŒ
'YTsUK' = 'http' XOR key32
ãã®åŸãããŒãèšç®ããæ®ãã®3ã€ã®æ¢ç¥ã®ãã€ãã§æ€èšŒããããšãã§ããŸãã ããããããŒãæ€çŽ¢æååèªäœã®é·ãã§ããå Žåã説æãããŠããã¢ãããŒãã¯æ©èœããŸããã ãªãããã®çç±ã§ãå°ããªç·ãã¡ã¯äœã§ãããŸãããå®éã«åœŒããå©ãããã®ã§ã¯ãããŸããã
çµã¿åãã
ããšãã°ãã¡ãœãããçµã¿åãããŸãã URLãå é ããæåŸãŸã§ãããã«ãã€ãã§ããããŠå€æ°ããŒã§poksorsyaã«æžã蟌ã¿ãŸãã ã¯ããäžéšã®èªååã«ã¯æ··ä¹±ãæãå¯èœæ§ããããŸãã å®éãããã¯ãã®ãããªãã¡ã€ã«ã®æ£åžžãªæ€åºã劚ããŸããã ãããŠããŠã€ã«ã¹åæè ã¯ãã«ãŠã§ã¢ãç解ãããšããã«ãReverseã¡ãœããïŒUnicodeïŒLinearXorïŒstreamïŒïŒïŒããã³ãŒãã«è¿œå ããŸãããã®åŸããã¹ãŠã®å€ãããŒãžã§ã³ãšæ°ããããŒãžã§ã³ãèªåçã«åŸ©å·åãããŸãã
éãã
説æãããŠããæå·åæ¹æ³ã®å¥ã®ã¢ããªã±ãŒã·ã§ã³ïŒããã°ã©ã ã®éããã ããªããèª å®ãªããã°ã©ãã§ãããããã°ã©ã ã®ã³ããŒã顧客ã®VasilyãšGeorgeã«æž¡ãããšããŸãã ãããããšãã¥ã¢ã«ããšã°ã¬ãŽãªãŒã®æ¹ãè¯ãã§ãã ãããŠãããªãã¯åœŒãã®ãã¡ã®1人ãããã°ã©ã ãå ¬éããŠããã®ãã©ããç¥ãããã§ãã ãœãŒã¹ã³ãŒãã§ã¯æ¬¡ã®ããã«èšè¿°ã§ããŸãã
#pragma data_segïŒ "ãtext"ïŒ
extern char WATERMARK [] = "uQPWâºâ} _â²WTWâº"; //ããšãã¯ãŒãã®ã³ããŒãXOR FF
ã³ã³ãã€ã«åŸãæå·åãããè¡ã¯å®è¡å¯èœãã¡ã€ã«ã«å«ãŸããŸãããæ€åºã¯å®¹æã§ã¯ãããŸããã çµå±ã®ãšãããäœãã©ãã§æ¢ãã¹ããã¯ããããŸããã
ããããå ã»ã©ããã£ãããã«ãEdwardã®ã³ããŒããããªãã¯ãã¡ã€ã³ã«å ¥ã£ãå ŽåãGregoryã«ã¯ããã°ã©ã ã®2ã€ã®ããŒãžã§ã³ãããããããã®éããç°¡åã«èŠã€ããŠæå·ã解ãããšãã§ããŸãã ã°ã¬ãŽãªãŒã¯ä»ã®äººã®ã³ããŒãåœé ã§ããããã«ãªããŸãã
çµè«ïŒ
ããã ãã§ãã ããã€ãã®ç°¡åãªæå·åæ¹æ³ã«ç²Ÿéãããããããªã圹ã«ç«ããªãã®ããèŠã€ããŸããã 質åãã³ã¡ã³ããããå Žå-çŽ æŽããããæ¬åœã«æ¥œãã¿ã«ããŠããŸãã è³æãåçŽããããšæãããå Žåã¯ãåããããã¯ã«é¢ãããŠã€ã«ã¹åæã®åéã§ã®å®äŸããããŸãã
ãŠã€ã«ã¹ïŒææè ïŒã¯ãææãããã¡ã€ã«ã«ãã®æ¬äœãåã蟌ã¿ãŸãã 圌ã®äœã¯äžå®ã§ããã圌ã¯æ¬¡ã®ãããªæ¬äŒŒä¹±æ°ã§DWORDãããã£ãŠæŠããŸãã
srandïŒããŒïŒ;
æå·å[0] =æ¬äœ[0] XOR randïŒïŒ;
æå·åããã[1] = body [1] XOR randïŒïŒ;
...
ããŒãæã€ããã£ãã³ãŒãã¯ã被害è ã®ã³ãŒãã«ãã£ãŠãã¹ãã¢ãªã³ã°ããããŸãïŒãšã³ããªãã€ã³ããäžæçïŒã®ã§ãæå·åãããããã£ã䜿çšããŠæ€åºããå¿ èŠããããŸãã ããšãã°ããŠã€ã«ã¹ã®æ¬äœãnotepad.exeã³ãŒãã»ã¯ã·ã§ã³ã§ãããšæ³å®ã§ããŸãã
ã³ã³ãã€ã©ã§æãäžè¬çãªã¢ã«ãŽãªãºã ãæ¬äŒŒä¹±æ°ãžã§ãã¬ãŒã¿ãšããŠäœ¿çšãããããšãç¥ãããŠããŸã ã
seed = seed * 1103515245 + 12345; return (seed % ((unsigned int)RAND_MAX + 1));
å®å
šè¡šç€º
/* * This file is part of the libpayload project. * * It was originally taken from the OpenBSD project. * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <libpayload.h> static unsigned int next = 1; int rand_r(unsigned int *seed) { *seed = *seed * 1103515245 + 12345; return (*seed % ((unsigned int)RAND_MAX + 1)); } int rand(void) { return (rand_r(&next)); } void srand(unsigned int seed) { next = seed; }