There is currently no effective solution to the problem of poor prognosis and recurrence of HCC. The technology of immunotherapy and prognosis of genetic material has made continuous progress in recent years. In the study, a 5-gene signature was established for the prognosis of HCC through biological information, and the immune infiltration of HCC patients was studied. After studied HCC patients' immune infiltration, the paper screened the differential target genes of miR-126-3p in HCC downloaded from TCGA database, and uses WGCNA method to select the modular genes highly relevant to M2 macrophage. Then we use LASSO and COX regression analysis technology to establish the 5-gene signature. The nomogram is established by combining the prognostic score and clinical phenotype. Cibersort was empolyed to observe the immune infiltration in HCC patients. We revealed the biological pathways of HCC-related genes through GSEA and Metascape. The bioinformatics analysis of 2495 differential target genes finally constructed a 5-gene signature with a reliable prognostic ability (CDCA8, SLC41A3, PPM1G, TCOF1, GRPEL2). The combination of prognostic score and AJCC_Stage resulted in a more reliable prognosis ability. At the same time, 10 immune cells that are differentially expressed in HCC patients were also found. 8 GSEA pathways related to the prognosis were found. In the study, a reliable 5-gene signature was established based on the differential target gene of miR-126-3p to study the immune infiltration in HCC patients. It provides help for HCC-related prognosis research and immunotherapy.